Class: FluentValidation::Validators::InclusiveBetweenValidator
- Inherits:
-
AttributeValidator
- Object
- Validator
- AttributeValidator
- FluentValidation::Validators::InclusiveBetweenValidator
- Defined in:
- lib/fluent_validation/validators/inclusive_between_validator.rb
Instance Method Summary collapse
- #generate_failure_message(attribute_name, attribute_value) ⇒ Object
-
#initialize(from, to) ⇒ InclusiveBetweenValidator
constructor
A new instance of InclusiveBetweenValidator.
- #is_valid?(validator_context) ⇒ Boolean
Methods inherited from AttributeValidator
Methods inherited from Validator
Constructor Details
#initialize(from, to) ⇒ InclusiveBetweenValidator
Returns a new instance of InclusiveBetweenValidator.
6 7 8 9 |
# File 'lib/fluent_validation/validators/inclusive_between_validator.rb', line 6 def initialize(from, to) @from = from @to = to end |
Instance Method Details
#generate_failure_message(attribute_name, attribute_value) ⇒ Object
15 16 17 |
# File 'lib/fluent_validation/validators/inclusive_between_validator.rb', line 15 def (attribute_name, attribute_value) "#{attribute_name} must be between #{@from} and #{@to}. You entered #{attribute_value}." end |
#is_valid?(validator_context) ⇒ Boolean
11 12 13 |
# File 'lib/fluent_validation/validators/inclusive_between_validator.rb', line 11 def is_valid?(validator_context) validator_context.attribute_value >=@from && validator_context.attribute_value <= @to end |