Class: HashValidator::Validator::EnumerableValidator
- Defined in:
- lib/hash_validator/validators/enumerable_validator.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ EnumerableValidator
constructor
A new instance of EnumerableValidator.
- #presence_error_message ⇒ Object
- #should_validate?(rhs) ⇒ Boolean
- #validate(key, value, validations, errors) ⇒ Object
Constructor Details
#initialize ⇒ EnumerableValidator
Returns a new instance of EnumerableValidator.
2 3 4 |
# File 'lib/hash_validator/validators/enumerable_validator.rb', line 2 def initialize super('_enumerable') # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end |
Instance Method Details
#presence_error_message ⇒ Object
10 11 12 |
# File 'lib/hash_validator/validators/enumerable_validator.rb', line 10 def 'value from list required' end |
#should_validate?(rhs) ⇒ Boolean
6 7 8 |
# File 'lib/hash_validator/validators/enumerable_validator.rb', line 6 def should_validate?(rhs) rhs.is_a?(Enumerable) end |
#validate(key, value, validations, errors) ⇒ Object
14 15 16 17 18 |
# File 'lib/hash_validator/validators/enumerable_validator.rb', line 14 def validate(key, value, validations, errors) unless validations.include?(value) errors[key] = end end |