Class: LIVR::Rules::Special::Email
- Inherits:
-
LIVR::Rule
- Object
- LIVR::Rule
- LIVR::Rules::Special::Email
- Defined in:
- lib/livr/rules/special.rb
Instance Method Summary collapse
Methods inherited from LIVR::Rule
Constructor Details
This class inherits a constructor from LIVR::Rule
Instance Method Details
#call(value, user_data, field_results) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/livr/rules/special.rb', line 6 def call(value, user_data, field_results) return if is_no_value(value) return 'FORMAT_ERROR' if !is_primitive(value) value = value.to_s email_re = /^([\w\-_+]+(?:\.[\w\-_+]+)*)@((?:[\w\-]+\.)*\w[\w\-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i return "WRONG_EMAIL" unless email_re.match(value) return "WRONG_EMAIL" if /\@.*\@/.match(value) return "WRONG_EMAIL" if /\@.*_/.match(value) return end |