From 8ac79a02de09823ce8b6a0af3140163845903b58 Mon Sep 17 00:00:00 2001 From: codeuri Date: Thu, 30 Mar 2017 15:49:17 +0300 Subject: [PATCH 1/3] Email validation upgrade Changed regexp rule for email with 4 domain level (my-email@university.student.vic.edu.au). This regexp was tested on more then 50 emails. --- src/validators.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validators.js b/src/validators.js index 273b6c02..eac85128 100644 --- a/src/validators.js +++ b/src/validators.js @@ -106,7 +106,7 @@ Form.validators = (function() { options = _.extend({ type: 'email', message: this.errMessages.email, - regexp: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i + regexp: /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i }, options); return validators.regexp(options); From 065255836e4d4680450f04542843f96d1bafc2f6 Mon Sep 17 00:00:00 2001 From: Yuri Date: Thu, 30 Mar 2017 17:59:12 +0300 Subject: [PATCH 2/3] Upgrade update email test Upgrade update email test for new validation regexp.Test passed. --- test/validators.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/validators.js b/test/validators.js index 76bea8da..3da2770f 100644 --- a/test/validators.js +++ b/test/validators.js @@ -309,6 +309,8 @@ equal(fn('http://example.com/path'), undefined) equal(fn('http://www.example.com/path/1/2'), undefined) equal(fn('http://www.example.com/path/1/2?q=str'), undefined) + equal(fn('email@domain.name.name.name.name'), undefined) + equal(fn('email.john+smith@domain.name'), undefined) }) })(); From cd381ebc13ac5f3022a161a3864ee89ad7612805 Mon Sep 17 00:00:00 2001 From: Yuri Date: Thu, 30 Mar 2017 18:04:03 +0300 Subject: [PATCH 3/3] Fix email test commit --- test/validators.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/validators.js b/test/validators.js index 3da2770f..0144f421 100644 --- a/test/validators.js +++ b/test/validators.js @@ -274,6 +274,8 @@ equal(fn('email@domain-one.com'), undefined) equal(fn('_______@domain.com'), undefined) equal(fn('email@domain.name'), undefined) + equal(fn('email@domain.name.name.name.name'), undefined) + equal(fn('email.john+smith@domain.name'), undefined) }) })(); @@ -309,8 +311,6 @@ equal(fn('http://example.com/path'), undefined) equal(fn('http://www.example.com/path/1/2'), undefined) equal(fn('http://www.example.com/path/1/2?q=str'), undefined) - equal(fn('email@domain.name.name.name.name'), undefined) - equal(fn('email.john+smith@domain.name'), undefined) }) })();