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
I would like to make a field optional, but if it is set, then it must be at least 8 chars long. I tried z.string().min(8).optional() (which seems to be typed valid in contrast to z.string().optional().min(3)). Unfortunately, it still requires the field to be set (with at least 8 chars) and the optional is ignored.
A possible workaround seems to be z.string().min(8).max(100).or(z.string().max(0)), but it looks quite ugly.
As more as I think about it, z.string().min(8).max(100).or(z.string().max(0)) seems to be completely ok. And optional does not mean that the string should be empty, but the field should be null.
I would like to make a field optional, but if it is set, then it must be at least 8 chars long. I tried
z.string().min(8).optional()
(which seems to be typed valid in contrast toz.string().optional().min(3)
). Unfortunately, it still requires the field to be set (with at least 8 chars) and theoptional
is ignored.A possible workaround seems to be
z.string().min(8).max(100).or(z.string().max(0))
, but it looks quite ugly.Originally posted by @medihack in #553
The text was updated successfully, but these errors were encountered: