diff --git a/lib/validation/validators/email.ts b/lib/validation/validators/email.ts index 2b1de151..cd449814 100644 --- a/lib/validation/validators/email.ts +++ b/lib/validation/validators/email.ts @@ -1,7 +1,7 @@ import { isString } from '../../support/Utils' /* eslint-disable-next-line no-control-regex */ -const regExp = /^(?:[A-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|[\x01-\x09\x0B\x0C\x0E-\x7F])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])+)\])$/i +const regExp = /^(?:[A-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|[\x01-\x09\x0B\x0C\x0E-\x7F])*")@(?:(?:[a-z0-9](?:[a-z0-9-_]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])+)\])$/i export function email(value: unknown): boolean { if (!isString(value)) { diff --git a/tests/validation/validators/email.spec.ts b/tests/validation/validators/email.spec.ts index 16c00a6a..4e4e1bdf 100644 --- a/tests/validation/validators/email.spec.ts +++ b/tests/validation/validators/email.spec.ts @@ -4,6 +4,7 @@ describe('validation/validators/email', () => { test('it validates whether the value is email', () => { expect(email('someone@gmail.com')).toBe(true) expect(email('someone@g-mail.com')).toBe(true) + expect(email('someone@g_mail.com')).toBe(true) expect(email('some!one@gmail.com')).toBe(true) expect(email('soMe12_one@gmail.com')).toBe(true) expect(email('someone@gmail.co')).toBe(true)