Class: HashValidator::Validator::AlphaValidator
- Inherits:
-
Base
- Object
- Base
- HashValidator::Validator::AlphaValidator
show all
- Defined in:
- lib/hash_validator/validators/alpha_validator.rb
Instance Attribute Summary
Attributes inherited from Base
#name
Instance Method Summary
collapse
Methods inherited from Base
#should_validate?, #validate
Constructor Details
Returns a new instance of AlphaValidator.
2
3
4
|
# File 'lib/hash_validator/validators/alpha_validator.rb', line 2
def initialize
super('alpha') end
|
Instance Method Details
#error_message ⇒ Object
6
7
8
|
# File 'lib/hash_validator/validators/alpha_validator.rb', line 6
def error_message
'must contain only letters'
end
|
#valid?(value) ⇒ Boolean
10
11
12
|
# File 'lib/hash_validator/validators/alpha_validator.rb', line 10
def valid?(value)
value.is_a?(String) && /\A[a-zA-Z]+\z/.match?(value)
end
|