-
Notifications
You must be signed in to change notification settings - Fork 12
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
[bug] Not rendering any error using ValidationError Component #18
Comments
Hi can you provide a code snippet of your form using |
|
Thanks. So When you render a validation error, you pass the field it should apply to, or no field if you want to render form-wide errors. You have the following code at the bottom of your form:
This is going to render just errors for the If your goal is to render email field errors, I suggest moving the validation error up under the email input. You can also add validation errors for the other fields by including the You can read more in the docs for ValidationError. |
Hi @colevscode I have added validation as per the doc. But validation doesn't seems to work for individual fields. It works in general if I do not add any specific field. Here is the code. It would be great if you can have a look at it.
Thank you. |
My first question is, do you have any validation rules set up that would display an error? Formspree can only validate rules that are set up in formspree's backend. Custom backend validation rules can be created via the formspree CLI using the The other way backend validation rules are created is if you use special fields that have associated implicit validation rules. For example, using the |
Okay, I wasn't aware of setting validation rules at the backend. I will have a look at it. Thank you. |
I came across the same problem, also unaware that validation rules need to be set up in the backend. It makes no mention in the docs it seems. It really should. Otherwise you are left thinking it works out of the box. |
Is there an existing issue for this?
Formspree React Version
2.4.0
Formspree Core Version
2.8.0
Current Behavior
No error is shown.
Expected Behavior
A validation error should be shown when using the component and there is an error is state.errors.
Steps To Reproduce
Forced an error by providing an invalid form id, passing the state.errors prop to the ValidationErrors component, form.errors having an error within the object, but you will not see anything displayed.
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
No response
Anything else?
Just a note I was using Vite/Astro and CRA to test this, however in the vite/astro version I was using npm and in the React version I was using yarn
The text was updated successfully, but these errors were encountered: