Class: Veto::MinLengthValidator
- Inherits:
-
AttributeValidator
- Object
- AbstractValidator
- AttributeValidator
- Veto::MinLengthValidator
- Defined in:
- lib/veto/validators/min_length_validator.rb
Instance Method Summary collapse
Methods inherited from AttributeValidator
Methods inherited from AbstractValidator
Constructor Details
This class inherits a constructor from Veto::AttributeValidator
Instance Method Details
#validate(entity, attribute, value, errors, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/veto/validators/min_length_validator.rb', line 5 def validate entity, attribute, value, errors, ={} min = .fetch(:with) = .fetch(:message, :min_length) on = .fetch(:on, attribute) if value.nil? || value.length < min errors.add(on, , min) end end |