Class: HashValidator::Validator::Ipv6Validator
- Inherits:
-
Base
- Object
- Base
- HashValidator::Validator::Ipv6Validator
show all
- Defined in:
- lib/hash_validator/validators/ipv6_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 Ipv6Validator.
4
5
6
|
# File 'lib/hash_validator/validators/ipv6_validator.rb', line 4
def initialize
super('ipv6') end
|
Instance Method Details
#error_message ⇒ Object
8
9
10
|
# File 'lib/hash_validator/validators/ipv6_validator.rb', line 8
def error_message
'is not a valid IPv6 address'
end
|
#valid?(value) ⇒ Boolean
12
13
14
15
16
17
18
19
|
# File 'lib/hash_validator/validators/ipv6_validator.rb', line 12
def valid?(value)
return false unless value.is_a?(String)
addr = IPAddr.new(value)
addr.ipv6?
rescue IPAddr::Error, IPAddr::InvalidAddressError
false
end
|