diff --git a/src/standard-validators.js b/src/standard-validators.js index 1929b36..a3435a8 100644 --- a/src/standard-validators.js +++ b/src/standard-validators.js @@ -312,7 +312,8 @@ export function config (validation) { ]); // email regex from https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address - validation.addValidator("email", {validate: "isTrue", value: /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, + // updated to block Intranet email address user@server1 as it's rarely used nowadays + validation.addValidator("email", {validate: "isTrue", value: /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/, message: "not a valid email"}); // unique. need to access neighbours diff --git a/test/standard-transformers-and-validators/email.spec.js b/test/standard-transformers-and-validators/email.spec.js index 4396344..0474321 100644 --- a/test/standard-transformers-and-validators/email.spec.js +++ b/test/standard-transformers-and-validators/email.spec.js @@ -12,6 +12,7 @@ test('email: tests email', t => { // shortcut rule = {a: "email"}; t.deepEqual(v.validate({a: 'c'}, rule), {a: ["not a valid email"]}); + t.deepEqual(v.validate({a: 'ab@test'}, rule), {a: ["not a valid email"]}); t.equal(v.validate({a: 'ab@test.com'}, rule), undefined); t.end(); });