Open M0hammedImran opened 1 year ago
Are you able to give a code example?
const scheme = z.string().email();
const email = "pawan.anand@%9y8325&%#%$&#$R%&#$%R&#$%R&%#$R%%^^%5rw3ewe.r.ef.d.d.d.d.d.aaaa.wef.co";
scheme.parse(email); //don't throw an error
According to this site (link) the domain can contains:
Behind the scenes zod uses this regex to validate email addresses: https://github.com/colinhacks/zod/blob/a57fc2da3c48a5a2270e9684017d8bc056af8a40/src/types.ts#L523-L524
If you would like a different regex to do this, you can use something like these:
// completely custom regex
const schema = z.string().regex( /some regex/ )
// custom regex that must match the zod email regex
const schema = z.string().email().regex( /some regex/ )
I created a pull request and for me this is a valid change because can prevent some issues
Another example of email that works but, I believe, is invalid:
invalid@foo.....com
Another example of email that works but, I believe, is invalid:
invalid@foo.....com
This doesn't pass the test for the default regex.
This doesn't pass the test for the default regex.
I disagree.
const schema = z.string().email()
console.log( schema.safeParse( 'invalid@foo.....com' ).success ) // true
Currently, I'm able to pass this as email and get no issues.