Class: Respect::MultipleOfValidator
- Inherits:
-
Validator
- Object
- Validator
- Respect::MultipleOfValidator
- Defined in:
- lib/respect/multiple_of_validator.rb
Instance Method Summary (collapse)
-
- (MultipleOfValidator) initialize(multiplier)
constructor
A new instance of MultipleOfValidator.
- - (Object) validate(value)
Methods inherited from Validator
Constructor Details
- (MultipleOfValidator) initialize(multiplier)
A new instance of MultipleOfValidator
3 4 5 |
# File 'lib/respect/multiple_of_validator.rb', line 3 def initialize(multiplier) @validator = DivisibleByValidator.new(multiplier) end |
Instance Method Details
- (Object) validate(value)
7 8 9 10 11 12 13 14 |
# File 'lib/respect/multiple_of_validator.rb', line 7 def validate(value) begin @validator.validate(value) rescue ValidationError => e raise ValidationError, e..sub(/\bdivisible by\b/, "a multiple of") end end |