Class: Booth::Syntaxes::Domain

Inherits:
Object
  • Object
show all
Includes:
Calls
Defined in:
lib/booth/syntaxes/domain.rb

Overview

Checks for a fully quantified domain name (FQDN).

Instance Method Summary collapse

Instance Method Details

#callObject

Example:

“‘ruby Booth::Syntaxes::Domain.call(’example.com’).valid_domain #=> ‘example.com’ Booth::Syntaxes::Domain.call(‘nonesense’).valid_domain #=> ‘nil’ “‘

Returns:

Tron Data object with

  • #valid_domain - nil or the syntactically valid domain name as String.



24
25
26
27
28
29
30
31
32
# File 'lib/booth/syntaxes/domain.rb', line 24

def call
  # Do we need to allow "localhost" in test env?
  # Maybe it's simpler/safer to run tests against "example.localhost" instead.
  return Tron.success(:valid_domain_syntax, valid_domain: input.to_s) if regexp.match(input)

  Tron.failure(:invalid_domain_syntax, invalid_domain: input.to_s,
                                       valid_domain: nil,
                                       public_message:)
end