You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using AutoForm with JSON Schema, if AutoForm has onValidate property, schema validation does not work. Remove the onValidate and schema validation works. Remove it and it it stops working. The test onValidate is simply returning null.
It appears that if onValidate returns the error, it works. However, the documentation at https://uniforms.tools/docs/api-forms/#props-1 seems to suggest returning null to skip async validation, so this is misleading. Also, in previous versions, I returned null from onValidate and had no problem so this seems to have changed in recent versions.
Hi @chiester. There's a misunderstanding regarding how the onValidate works. This function receives both the model as well as the validation error and decides what the resulting error is.
Returning null at all times simply disabled validation, as whenever the form validates, it passes the validation result through onValidate and it says "none" (null means no error).
In your case, if you'd like to have some additional async validation, then it should look like this instead:
asyncfunctiononValidate(model,error){// If there's any error from the schema, leave it.if(error){returnerror;}// If the schema passed, validate using our custom logic.returnawaitvalidate(model);}
Using AutoForm with JSON Schema, if AutoForm has onValidate property, schema validation does not work. Remove the onValidate and schema validation works. Remove it and it it stops working. The test onValidate is simply returning null.
Reproduction repository, /~https://github.com/chiester/uniforms-onvalidate-bug
CodeSandbox: https://codesandbox.io/p/github/chiester/uniforms-onvalidate-bug
The text was updated successfully, but these errors were encountered: