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
Copy file name to clipboardExpand all lines: docs/content/docs/reference/configuration/output.mdx
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1080,6 +1080,67 @@ Control which schemas are generated.
1080
1080
1081
1081
Add preprocess functions to schemas.
1082
1082
1083
+
### params
1084
+
1085
+
**Type:**[`Mutator`](#mutator)
1086
+
1087
+
Inject a Zod `params` argument (e.g. `{ error: ... }`) into every generated validator. The referenced function is called once per validator at schema construction time and receives codegen-time context (operation, location, schema name, field path, validator name). Whatever it returns is passed as the trailing argument of the call.
1088
+
1089
+
Useful for i18n error keys, branded error messages, or any field-aware customisation that Zod's global error map cannot disambiguate on its own (because `issue.path` does not carry operation/schema identity).
- Skipped on modifiers (`optional`, `nullable`, `nullish`, `default`, `describe`) and structural calls (`object`, `array`, `tuple`, `union`, `rest`, `passthrough`, `strict`).
1141
+
1142
+
Static messages are supported by returning a plain string: `return { error: 'My message' }`. The function may return `undefined` to fall back to Zod defaults for a specific call.
0 commit comments