Class: ValidationKit::EmailValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ValidationKit::EmailValidator
- Defined in:
- lib/validation_kit/email_validator/email_validator.rb
Constant Summary collapse
- EMAIL_ADDRESS_RE =
This hangs ruby if you have more than one validates_as_email rule in the same object Commenting it out for now Using the one found at <fightingforalostcause.net/misc/2006/compare-email-regex.php> EMAIL_ADDRESS_RE = /^((([a-z]|d||[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])+(.(|d||[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])+)*)|((x22)((((x20|x09)*(x0dx0a))?(x20|x09)+)?((|x21||[x5d-x7e]|)|(\([x01-x09x0bx0cx0d-x7f]|))))*(((x20|x09)*(x0dx0a))?(x20|x09)+)?(x22)))@(((|d|)|(([a-z]|d|)([a-z]|d|-|.|_|~|)*([a-z]|d|))).)+(([a-z]|)|(([a-z]|)([a-z]|d|-|.|_|~|)*([a-z]|))).?$/i
/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/i
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/validation_kit/email_validator/email_validator.rb', line 10 def validate_each(record, attribute, value) unless EMAIL_ADDRESS_RE.match(value) model_name = record.class.to_s = I18n.t("activerecord.errors.models.#{model_name.underscore}.attributes.#{attribute}.invalid", :default => [:"activerecord.errors.models.#{model_name.underscore}.invalid", [:message], :'activerecord.errors.messages.invalid']) record.errors.add(attribute, ) end end |