Class: Respect::LessThanOrEqualToValidator
- Inherits:
-
Validator
- Object
- Validator
- Respect::LessThanOrEqualToValidator
- Defined in:
- lib/respect/less_than_or_equal_to_validator.rb
Instance Method Summary (collapse)
-
- (LessThanOrEqualToValidator) initialize(max)
constructor
A new instance of LessThanOrEqualToValidator.
- - (Object) validate(value)
Methods inherited from Validator
Constructor Details
- (LessThanOrEqualToValidator) initialize(max)
A new instance of LessThanOrEqualToValidator
3 4 5 |
# File 'lib/respect/less_than_or_equal_to_validator.rb', line 3 def initialize(max) @max = max end |
Instance Method Details
- (Object) validate(value)
7 8 9 10 11 |
# File 'lib/respect/less_than_or_equal_to_validator.rb', line 7 def validate(value) unless value <= @max raise ValidationError, "#{value} is not less than or equal to #@max" end end |