Skip to content

Validation is not run on NestedForms #182

@samboylett

Description

@samboylett

I have a yup object with a custom validation (test) which relies on the entire object. As validation is only triggered on changing fields, this test is never ran. It would be good if there was a way to trigger validation on the entire form/nested form. (e.g. add the validateOn/noValidate props to Form/NestedForm).

For now I have done this as a work around (code is copied from NestedForm and modified so it will run the validation on it):

    const [, meta] = useField(name);

    return (
      <Form
        as="div"
        schema={schema}
        value={meta.value}
        onChange={meta.onChange}
        onError={(nextErrors) => meta.onError(prefix(nextErrors, name))}
        errors={unprefix(meta.errors, name)}
        context={meta.context}
      >

Thanks!

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