Class: HashValidator::Validator::AlphanumericValidator
- Defined in:
- lib/hash_validator/validators/alphanumeric_validator.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ AlphanumericValidator
constructor
A new instance of AlphanumericValidator.
- #presence_error_message ⇒ Object
- #validate(key, value, _validations, errors) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ AlphanumericValidator
Returns a new instance of AlphanumericValidator.
2 3 4 |
# File 'lib/hash_validator/validators/alphanumeric_validator.rb', line 2 def initialize super('alphanumeric') # The name of the validator end |
Instance Method Details
#presence_error_message ⇒ Object
6 7 8 |
# File 'lib/hash_validator/validators/alphanumeric_validator.rb', line 6 def 'must contain only letters and numbers' end |
#validate(key, value, _validations, errors) ⇒ Object
10 11 12 13 14 |
# File 'lib/hash_validator/validators/alphanumeric_validator.rb', line 10 def validate(key, value, _validations, errors) unless value.is_a?(String) && valid_alphanumeric?(value) errors[key] = end end |