Class: Respect::DivisibleByValidator
- Inherits:
-
Validator
- Object
- Validator
- Respect::DivisibleByValidator
- Defined in:
- lib/respect/divisible_by_validator.rb
Instance Method Summary (collapse)
-
- (DivisibleByValidator) initialize(divider)
constructor
A new instance of DivisibleByValidator.
- - (Object) validate(value)
Methods inherited from Validator
Constructor Details
- (DivisibleByValidator) initialize(divider)
A new instance of DivisibleByValidator
3 4 5 |
# File 'lib/respect/divisible_by_validator.rb', line 3 def initialize(divider) @divider = divider end |
Instance Method Details
- (Object) validate(value)
7 8 9 10 11 |
# File 'lib/respect/divisible_by_validator.rb', line 7 def validate(value) unless (value % @divider).zero? raise ValidationError, "#{value} is not divisible by #@divider" end end |