Class: KDL::Types::Hostname::Validator
- Inherits:
-
Object
- Object
- KDL::Types::Hostname::Validator
- Defined in:
- lib/kdl/types/hostname/validator.rb
Direct Known Subclasses
Constant Summary collapse
- PART_RGX =
/^[a-z0-9_][a-z0-9_\-]{0,62}$/i
Instance Attribute Summary collapse
-
#string ⇒ Object
(also: #ascii, #unicode)
readonly
Returns the value of attribute string.
Instance Method Summary collapse
-
#initialize(string) ⇒ Validator
constructor
A new instance of Validator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(string) ⇒ Validator
Returns a new instance of Validator.
13 14 15 |
# File 'lib/kdl/types/hostname/validator.rb', line 13 def initialize(string) @string = string end |
Instance Attribute Details
#string ⇒ Object (readonly) Also known as: ascii, unicode
Returns the value of attribute string.
9 10 11 |
# File 'lib/kdl/types/hostname/validator.rb', line 9 def string @string end |
Instance Method Details
#valid? ⇒ Boolean
17 18 19 20 21 |
# File 'lib/kdl/types/hostname/validator.rb', line 17 def valid? return false if @string.length > 253 @string.split('.').all? { |x| valid_part?(x) } end |