Soft validation #4465
-
|
When building a Quiz for example. We want to validate the answer; if it's wrong or correct. I was hoping the bails option would make this possible, but can't find a good working example of this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Moved to discussions since its more of a question. You have a few options, since your rules do not block the submission using You could use const { validate, values } = useForm();
async function onSubmit() {
// if you are interested in validating
const result = await validate();
// submit your data
sendToApi(values);
// do what you want next
step.value++;
} |
Beta Was this translation helpful? Give feedback.
-
|
Thank you! Using First I thought it didn't work because I used a |
Beta Was this translation helpful? Give feedback.
Moved to discussions since its more of a question.
You have a few options, since your rules do not block the submission using
optionalornullablewithyuporzodshould do the trick. If you are using global rules then you can do the following:You could use
validateinstead of usinghandleSubmit.