diff --git a/packages/type/src/validator.ts b/packages/type/src/validator.ts index 1d429c8a1..80aae846d 100644 --- a/packages/type/src/validator.ts +++ b/packages/type/src/validator.ts @@ -45,7 +45,7 @@ export type AfterDate = ValidatorMeta<'afterDate', [T]>; export type BeforeNow = ValidatorMeta<'beforeNow'>; export type AfterNow = ValidatorMeta<'afterNow'>; -export const EMAIL_REGEX = /^\S+@\S+$/; +export const EMAIL_REGEX = /^\S+@\S+\.\S+$/; export type Email = string & Pattern; /** diff --git a/packages/type/tests/validation.spec.ts b/packages/type/tests/validation.spec.ts index 256648e1e..4b96425b9 100644 --- a/packages/type/tests/validation.spec.ts +++ b/packages/type/tests/validation.spec.ts @@ -22,9 +22,10 @@ test('email', () => { expect(is('@')).toBe(false); expect(validate('peter@example.com')).toEqual([]); - expect(validate('nope')).toEqual([{ path: '', code: 'pattern', message: `Pattern ^\\S+@\\S+$ does not match`, value: 'nope' }]); - expect(validate('nope@')).toEqual([{ path: '', code: 'pattern', message: `Pattern ^\\S+@\\S+$ does not match`, value: 'nope@' }]); - expect(validate('@')).toEqual([{ path: '', code: 'pattern', message: `Pattern ^\\S+@\\S+$ does not match`, value: '@' }]); + expect(validate('nope')).toEqual([{ path: '', code: 'pattern', message: `Pattern ^\\S+@\\S+\\.\\S+$ does not match`, value: 'nope' }]); + expect(validate('nope@')).toEqual([{ path: '', code: 'pattern', message: `Pattern ^\\S+@\\S+\\.\\S+$ does not match`, value: 'nope@' }]); + expect(validate('nope@gmail')).toEqual([{ path: '', code: 'pattern', message: `Pattern ^\\S+@\\S+\\.\\S+$ does not match`, value: 'nope@gmail' }]); + expect(validate('@')).toEqual([{ path: '', code: 'pattern', message: `Pattern ^\\S+@\\S+\\.\\S+$ does not match`, value: '@' }]); }); test('minLength', () => {