Skip to content

Ability to clear/reset validation #58

@Sicria

Description

@Sicria

Is it possible to clear the validation state of the form programmatically?

Use-case: I have a form with conditional fields that are controlled via a select, if you choose option1 and submit without a value it creates a validation error on fieldA, if you choose option2 it shows fieldB, the form validation is still success: false due to the previous submission.

Ideally, when switching between fields/schemas I'd like to clear the validation that was done previously.

Calling zo.validate() isn't ideal as that means all of the fields will then be validated, rather than being clean/fresh.


Perhaps a resetValidation or validationReset could be added here?

const validationReset = useCallback(() => {
  setValidation(null);
}, []);

Perhaps it could be zo.validate({ reset: true }) or something similar if the above option isn't ideal?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions