Class: Openapi3Parser::Validators::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi3_parser/validators/email.rb

Constant Summary collapse

REGEX =

Regex is sourced from HTML specification: html.spec.whatwg.org/#e-mail-state-(type=email)

%r{
  \A
  [a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+
  @
  [a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?
  (?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*
  \Z
}x.freeze

Class Method Summary collapse

Class Method Details

.call(input) ⇒ Object


17
18
19
20
# File 'lib/openapi3_parser/validators/email.rb', line 17

def self.call(input)
  message = %("#{input}" is not a valid email address)
  message unless REGEX.match(input)
end