-
-
Notifications
You must be signed in to change notification settings - Fork 197
Description
This is rather a Request for Comments for a feature I want to PR. I wonder if I should name the new TypeBox field message
, errorMessage
or something else. I am going to open the PR once there is feetback from maintainers.
Is your feature request related to a problem? Please describe.
There is no way to add custom error messages to the TypeBox resolver. E.g. my use case is a consent checkbox and rather than getting userConsent must be true
for a consent checkbox I would need to display a user-friendly message like Your consent is required
, but I can't. Alternatives like Zod and Yup have an easy message property for such cases, but TypeBox doesn't have one
Describe the solution you'd like
-
Reference a new field on TypeBox schemas that will hold the message. TypeBox itself throws no errors for additional fields, so it can be anything:
message
,errorMessage
etc. I wan to go withmessage
, but I would highly appreciate if you would comment on that. -
Modify resolver to read that new field, something along those lines: Custom errors using TypeCompiler sinclairzx81/typebox#500 (comment)
Describe alternatives you've considered
No good alternatives other than switching to Zod