Class: EnvValidator::Types::Email

Inherits:
Base
  • Object
show all
Defined in:
lib/env_validator/types.rb

Constant Summary collapse

EMAIL_REGEX =

Basic email regex - not RFC compliant but good enough for most cases

/\A[^@\s]+@[^@\s]+\.[^@\s]+\z/

Instance Method Summary collapse

Methods inherited from Base

#coerce

Instance Method Details

#validate(value) ⇒ Object

Raises:



99
100
101
102
103
# File 'lib/env_validator/types.rb', line 99

def validate(value)
  raise TypeError, "Expected valid email address, got #{value.inspect}" unless value.to_s.match?(EMAIL_REGEX)

  true
end