Module: RubyEmail
- Defined in:
- lib/ruby_email/core.rb,
lib/ruby_email/public.rb
Overview
Defined Under Namespace
Constant Summary collapse
- ATEXT =
one valid character (not . because used to separe domains)
'([A-Za-z0-9!#\$%&\'*\+\-/=\?\^_`\{\}\|~])'- ATOM =
"#{ATEXT}+"- DOT_ATOM_TEXT =
"(#{ATOM})(\\.#{ATOM})*"- VALIDE =
email grammar
"(?<local>#{DOT_ATOM_TEXT})@(?<domain>#{DOT_ATOM_TEXT})"- REGEXP =
regexp to validate complete email
Regexp.new "\\A#{VALIDE}\\Z"
Class Method Summary collapse
-
.match(str) ⇒ MatchData or NilClass
Check if the string is a valid email and details how.
-
.validates?(str) ⇒ TrueClass or FalseClass
Check if the String is a valid email.
Class Method Details
.match(str) ⇒ MatchData or NilClass
Check if the string is a valid email and details how
24 25 26 27 |
# File 'lib/ruby_email/core.rb', line 24 def self.match str raise ArgumentError, "Cannot validate a `#{str.class}`. Only `String` can be." unless str.is_a?(String) str.match(REGEXP) end |
.validates?(str) ⇒ TrueClass or FalseClass
Check if the String is a valid email
16 17 18 |
# File 'lib/ruby_email/core.rb', line 16 def self.validates? str !!match(str) end |