Skip to content
Discussion options

You must be logged in to vote

Hi @etiennelacoursiere! I'm Dosu and I’m helping the zod team.

Zod doesn't automatically substitute type names (like string) with field names (like password) in its built-in error messages. This is because Zod's error messages are generated based on the type validation, not the field name, and schema metadata (such as a field "title") isn't reliably accessible in error maps due to how transformations work in Zod v4 discussion.

To achieve your goal, you can customize error messages for each validation step using the error parameter. For example, you can set a custom error for the min check on your password field:

export const LoginSchema = z.object({
  email: z.email(),
  password: z.string(

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by etiennelacoursiere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant