Custom error message based on condition #943
Unanswered
WangHansen
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was wondering how to achieve the following validation for
zod
withtypebox
:The result is:
Basically show error message for one check at a time. This is the current behavior if no custom error message is given. But if I use the custom error function, then only one message can be used:
For the code above, whether entering a string less than 5 chars or not matching the pattern, it will only show "Name must be at least 5 or more characters and match pattern".
Maybe the key of failed property can be given so message can be a function:
Also according to the elysia document, I can provide an
error
prop and custom error message will be displayed. But it is not working, is there some special settings I need to do? I am on0.32.34
Beta Was this translation helpful? Give feedback.
All reactions