export const insertTagSchema = createInsertSchema(tags, { name: (schema) => schema.name .min(2, "Please enter a tag name of at least 2 characters") .max(256, "Please enter a tag name of 256 characters or less"),...
export const insertTagSchema = createInsertSchema(tags, { name: (schema) => schema.name .min(2, "Please enter a tag name of at least 2 characters") .max(256, "Please enter a tag name of 256 characters or less"),...
I use that
insertTagSchema
insertTagSchema
in a react-hook-form
resolver: zodResolver(insertTagSchema),
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"),
.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.