-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
ArrayInput does not show validation errors if using schema validation (with yup) #8153
Comments
Thanks for reporting this. |
I'm afraid it has high chances of being related to #8118 😬 |
Apparently the issue is limited to controlling the array's size, because adding a control over the array fields like this actually works: const innerSchema = yup.object().shape({
- name: yup.string().optional(),
+ name: yup.string().required('Error 2'),
}); |
@slax57 This though is not the problem I reported. This validation checks on the schema of a single item in the array, and it presents the error messge related to the Here is an example with a different validation applied mirrored in both cases: https://stackblitz.com/edit/github-mccsfc?file=src%2Ftags%2FTagCreate.tsx,src%2Fcomments%2FCommentCreate.tsx I'll add it to the issue description as well |
Some additional info we'd like to add:
|
@slax57 thank you very much! Will the issue you entioned with yup errors not showing on bot levels be addressed down the line, or will it remain as is? Not that it's a big problem I'd just like to have the info |
@tommasogangemi You're welcome. |
Expected result
The
ArrayInput
shows the related error message when using a resolver for schema validation, as it happens when using thevalidate
prop.Actual result
When submitting the form the
ArrayInput
's label turns red, and there is no message shown where it should be (in the place of the helper text).Steps to reproduce:
Open up this stackblitz project, forked from your simple example.
The
TagCreate
component has a form with an array input that is validated via thevalidate
prop, and correctly shows the error when trying to submit.The
CommentCreate
component has a form with an array input that is validated by a resolver that uses a yup schema, as suggested by your docs. Thevalidation works as expected, but the error message does not correctly pop up under the input, that only shows a red label.Both the forms extract the error from the field the same way as it's done in the source code of ArrayInput, and the error is logged in the console. Here we can observe that the
error
retrieved has a different shape in the 2 cases.Related code:
In this example I try to validate the array with a yup native array schema method and a standard
validate
propIn this example I try to validate the array input based on a custom validation function mirrored in the native example and the yup example
Both of them result in the same exact misbehaviour
Other information:
I have recently upgraded the react-admin version from version 4.2.6 to version 4.3.1. The problem was not present in version 4.2.6 and the error message used to show up as expected
Environment
ArrayInput
commit history in the repo I might stretch out to say it was actually 4.3.0, but I have not tested that version)The text was updated successfully, but these errors were encountered: