string.max message not respected?
How do I refine my createInsertSchema to override the message for the max length of a string?
I have a mySqlTable defined named "tags".
From there I create an insert schema.
I use that
insertTagSchema
in a react-hook-form resolver: zodResolver(insertTagSchema),
.
If I enter 1 character I get the appropriate message from the .min. However, if I enter over 256 I get the default message ("String must contain at most 256 character(s)") for the max value instead of the message provided. If I set the .max smaller, like .max(25, "Please enter a tag name of 25 characters or less"),
, I see the message provided between 26 and 256 characters.
It seems like the schema refinement of .max adds a parsing step as opposed to refining the existing step.0 Replies