Class: SexyValidations::Validators::Length
- Inherits:
-
Object
- Object
- SexyValidations::Validators::Length
- Defined in:
- lib/sexy_validations/validators/length.rb
Class Method Summary collapse
Class Method Details
.validate(model, attribute, value, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sexy_validations/validators/length.rb', line 5 def self.validate(model, attribute, value, ) return unless value unless .is_a?(Hash) = { :within => , } end min = [:within].min if value.length < min model.errors.add(attribute, "zu kurz (mindestens #{min} Zeichen)") end max = [:within].max if value.length > max model.errors.add(attribute, "zu lang (maximal #{max} Zeichen)") end end |