valibot: Feat: Show required field errors instead of type error
Right now we write string()
and we pass “data type should be string”.
But how do we show the error this field is required instead of type error.
Can we modify the flatten
method?
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 1
- Comments: 26 (16 by maintainers)
It is easy to create a custom function that combines
string
andminLength(1)
Feel free to make a concrete proposal with sample code to change the API.
Thanks for the info. You can also format the Valibot Issues so that the errors are the same or similar to Vine. A Valibot Issue contains any basic info about the problem. With
reason: "type"
andinput: undefined
, you can detect that a value for a key was not specified.string
ist non optional by default. You only neednonOptional
if you reuse a schema that isoptional
. @ShivamJoker can you send me a code example with Zod?That doesn’t feel right. If we look at zod or any other schema validation they show the required field error.