Class: JSONSkooma::Validators::Hostname

Inherits:
Base
  • Object
show all
Defined in:
lib/json_skooma/validators/hostname.rb

Constant Summary collapse

HOSTNAME =
/(?=.{1,253}\.?\z)[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*\.?/
REGEXP =
/\A#{HOSTNAME}\z/i

Instance Method Summary collapse

Methods inherited from Base

assert?, call, inherited

Instance Method Details

#call(data) ⇒ Object

Raises:



10
11
12
13
14
# File 'lib/json_skooma/validators/hostname.rb', line 10

def call(data)
  return if REGEXP.match?(data.value)

  raise FormatError, "#{data} is not a valid hostname"
end