Skip to content

onChange and onBlur validation errors should prevent submission of form #490

Closed

Description

@crutchcorn

Currently, when using a field with:

<Field onChange={z.string().min(1)}>

When the user submits the form, it does not show a form error on submit. This causes headaches currently as it makes things harder to workflow properly.

Activity

  1. vikaskumar89 commented on Oct 31, 2023

    @vikaskumar89
    Contributor

    Hey @crutchcorn
    Can you assign this to me please

  2. MiirzaBaig commented on Nov 4, 2023

    @MiirzaBaig

    Can you aasign this issue to me?

  3. vikaskumar89 commented on Nov 4, 2023

    @vikaskumar89
    Contributor

    hey @I-MirzaBaig
    I am working on this. Could you pick any other open issue.

  4. MiirzaBaig commented on Nov 4, 2023

    @MiirzaBaig

    @vikaskumar89 Alright!

  5. vikaskumar89 commented on Nov 4, 2023

    @vikaskumar89
    Contributor

    Hey @crutchcorn
    The root cause of this error is because we have defined undefined for the submit cause that leads to validateSync returning early and not executing any onBlur/onChange validation.

    error rootcause:

    if (!validate) return

    One solution that comes to my mind is in case of submit cause, we can execute either onChange or onBlur validation(whichever is defined in the field) but this would lead to incorrect errorMap detail in the state as the errorMapKey would be submit and the error would correspond to onChange/onBlur.

    Do you have any alternate suggestion to fix this ?

  6. vikaskumar89 commented on Nov 4, 2023

    @vikaskumar89
    Contributor

    Due to this errorMap array, we are facing this issue in #486, as the errorMap is not clear after a valid value is entered.

  7. danteissaias commented on Nov 7, 2023

    @danteissaias

    Is there currently a workaround to this?

  8. vikaskumar89 commented on Nov 7, 2023

    @vikaskumar89
    Contributor

    @danteissaias yeah fix should be out in a couple of days.

  9. crutchcorn commented on Dec 3, 2023

    @crutchcorn
    MemberAuthor

    This fix is released in 0.10.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions