-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I add custom error to specific field? - ember-headless-form + ember-headless-form-yup + yup #143
Comments
this is all Would be interesting to see if it could be extended to support errors from "elsewhere" tho Discord convo: https://discord.com/channels/480462759797063690/483601670685720591/1110684877042487356 |
Discord discussion about this: |
Sorry for the late feedback here! If I understand you correctly, this is about rendering server-errors, right? If so, there is indeed no real support for that (yet). The thing with the existing validation API as touched on above, is that its purpose is to specifically prevent submitting the form as long as (client-side!) validation does not pass! But for errors that can only be known server-side, this is not suitable. Here we must submit the form, and when receiving errors back, render them within the form in the same way as if they happened client-side, right? As this addon is headless, nothing really is preventing you from doing the rendering of those errors where and how you need them. However I acknowledge this is not really convenient. Especially if you want to support the same a11y standards as what is already baked into the existing implementation, like applying So ideally you would be able to pass something like this, and all the error rendering happens as if it was a client-side validation error: <HeadlessForm
@onSubmit={{this.onSubmit}}
@onInvalid={{this.handleInvalidForm}}
@validate={{validate-yup this.schema}}
@customErrors={{this.serversideErrorMap}}
as |form|
> Again, there is no support for this yet. But we could do this eventually in the future, when we get to alignment here! |
It looks like all I'm mostly thinking out loud, but it feels like this problem is only with If this case is unique to |
@ynotdraw this is about state of invalid form. Yup enable to validate this "on-the-fly". I meant something like management of current state of raised errors. Main question is how to update (or remove) errors that are stored in ember-headless-form that are there:
I did workaround for this already in my project, but this doesn't look nice and I wish there will be management of adding or removing errors manually somehow for specific attribute in form :) |
@simonihmig (@NullVoxPopuli recommend me to tag you there)
I am using ember-headless-form + ember-headless-form-yup + yup
I have
The text was updated successfully, but these errors were encountered: