Class: Veto::LessThanOrEqualToValidator
- Inherits:
-
AttributeValidator
- Object
- AbstractValidator
- AttributeValidator
- Veto::LessThanOrEqualToValidator
- Defined in:
- lib/veto/validators/less_than_or_equal_to_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 14 15 16 17 18 19 20 |
# File 'lib/veto/validators/less_than_or_equal_to_validator.rb', line 5 def validate entity, attribute, value, errors, ={} boundary = .fetch(:with) = .fetch(:message, :less_than_or_equal_to) on = .fetch(:on, attribute) begin v = Kernel.Float(value.to_s) nil rescue return errors.add(on, , boundary) end unless v <= boundary errors.add(on, , boundary) end end |