fix(email_validation): use truemail regexp
This commit is contained in:
parent
d9b6db8ebc
commit
2468d528fd
2 changed files with 10 additions and 1 deletions
|
@ -3,7 +3,11 @@ class StrictEmailValidator < ActiveModel::EachValidator
|
|||
# saying that it's quite permissive
|
||||
# but we want more, we want to ensure it's a domain with extension
|
||||
# so we append \.[A-Za-z]{2,}
|
||||
REGEXP = /\A(?<username>[^@[:space:]])+@(?<domain>[^@[:space:]\.])+(?<extensions>\.[[:alnum:].]{2,})\z/
|
||||
TRUEMAIL_REGEX_DOMAIN = /[\p{L}0-9]+([-.]{1}[\p{L}\p{N}\p{Pd}]*[\p{L}\p{N}]+)*\.\p{L}{2,63}/i.freeze
|
||||
TRUEMAIL_REGEX_EMAIL_PATTERN = %r{(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w\p{L}.+!~,'&%#*^`{}|\-/?=$]*)@(#{TRUEMAIL_REGEX_DOMAIN})\z)}.freeze
|
||||
|
||||
REGEXP = TRUEMAIL_REGEX_EMAIL_PATTERN
|
||||
|
||||
DATE_SINCE_STRICT_EMAIL_VALIDATION = Date.parse(ENV.fetch('STRICT_EMAIL_VALIDATION_STARTS_ON')) rescue 0
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
|
|
|
@ -60,6 +60,11 @@ describe Champs::EmailChamp do
|
|||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when value includes accents' do
|
||||
let(:value) { 'prenom.nom@etu.univ-rouen.fr' }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when value is the classic standard user@domain.ext' do
|
||||
let(:value) { 'username@mailserver.domain' }
|
||||
it { is_expected.to be_truthy }
|
||||
|
|
Loading…
Reference in a new issue