You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When looking through the json schema specs on emails and how zod handles them I realised there's a fundamental difference: while the json schema spec uses RFC 5321 for email and RFC 6531 for idn-email, zod uses a custom RegExp which it deems "reasonable".
This is where I wondered if matching zod.string().email() to "format": "email" actually makes sense, or if we should maybe use "pattern": "[regex from zod]" instead. Otherwise one could run into issues where an email is valid for the json schema, but invalid when using zod.
This issue extends to #40, where I'm currently adding RegExps for the aforementioned RFCs - which wouldn't be in line with how zod handles things and leads to enormous patterns being ejected.
I think this deserves a general answer, with options being
try to generate a json schema which best contains the information given to the zod schema (use "format": "idn-email")
generate a json schema which matches with the validations zod does (use "pattern": "[regex from zod]")
Hi!
When looking through the json schema specs on emails and how zod handles them I realised there's a fundamental difference: while the json schema spec uses RFC 5321 for
email
and RFC 6531 foridn-email
, zod uses a custom RegExp which it deems "reasonable".This is where I wondered if matching
zod.string().email()
to"format": "email"
actually makes sense, or if we should maybe use"pattern": "[regex from zod]"
instead. Otherwise one could run into issues where an email is valid for the json schema, but invalid when using zod.This issue extends to #40, where I'm currently adding RegExps for the aforementioned RFCs - which wouldn't be in line with how zod handles things and leads to enormous patterns being ejected.
I think this deserves a general answer, with options being
"format": "idn-email"
)"pattern": "[regex from zod]"
)@StefanTerdell
The text was updated successfully, but these errors were encountered: