T
TanStack2w ago
exotic-emerald

how to validate with yup since yup is Standard Schema compatible?

in very short, if i pass yup.number() to a onChange field validator i get an error async function passed to sync validator. i checked the ~standard prop of the schema and the validate prop is an async function. so it makes sense that the error is thrown since i see that the standardSchemaValidator checks this. but which is the right way to add the yup schema?
3 Replies
rare-sapphire
rare-sapphire2w ago
weird. I guess you can use onChangeAsync? but I'm fairly certain that sync/async is covered by standard schema spec
exotic-emerald
exotic-emeraldOP2w ago
yeah i tried it. it will work but i want to do different async serverside checks after sync checks i think the implementation of standard schema in yup is not 100% correct in each case the schema returns a async function under .validate
rare-sapphire
rare-sapphire2w ago
use the method instead then formApi.parseValuesWithSchemaAsync() lets you combine callbacks with other things as well as have standard schema

Did you find this page helpful?