Module: RubyEmail::Public
- Defined in:
- lib/ruby_email/public.rb
Overview
Only valid on the public internet. “toto@toto” is not valid, but “[email protected]” is good
Defined Under Namespace
Modules: String
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 =
"(?<local>#{DOT_ATOM_TEXT})@(?<domain>#{DOT_ATOM_TEXT}\\.#{DOT_ATOM_TEXT})"- REGEXP =
Regexp.new "\\A#{VALIDE}\\Z"
Class Method Summary collapse
-
.match(str) ⇒ MatchData or NilClass
Check if the string is a valid email on internet and details how.
-
.validates?(str) ⇒ TrueClass or FalseClass
Check if the String is a valid email on internet.
Class Method Details
.match(str) ⇒ MatchData or NilClass
Check if the string is a valid email on internet and details how
27 28 29 30 |
# File 'lib/ruby_email/public.rb', line 27 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 on internet
19 20 21 |
# File 'lib/ruby_email/public.rb', line 19 def self.validates? str !!match(str) end |