Sha256: 63fb0085978429c8a615ec40319d24504b444b8be94a67aa3e32e1f44b45def3
Contents?: true
Size: 610 Bytes
Versions: 1
Compression:
Stored size: 610 Bytes
Contents
require 'localized_each_validator' # Validates email addresses. Uses the @invalid_email@ error message key. # # @example # validates :email_address, email: true # # h2. Options # # | @:message@ | A custom message to use if the email is invalid. | # | @:allow_nil@ | If true, @nil@ values are allowed. | class EmailValidator < LocalizedEachValidator # Regular expression describing valid emails EMAIL_REGEX = "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}" error_key :invalid_email # @private def valid?(_, _, value) value =~ /^#{EMAIL_REGEX}$/i || value =~ /^.+\s+<#{EMAIL_REGEX}>$/i end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
email_validation-1.1.0 | lib/email_validation.rb |