Replies: 3 comments
-
This would be very useful, we hope it will be developed.... |
Beta Was this translation helpful? Give feedback.
0 replies
-
Working with arrays needs to have the index value to throw custom messages. This will be a great feature |
Beta Was this translation helpful? Give feedback.
0 replies
-
I've created a PR for this change: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I would like to ask a feature that add field index in error message when validating multiple fields. Let me explain it better.
First, I kindly ask you to visit this question on StackOverflow. If you have visited it, there is no much need to read the paragraphs below since they are near the same thing.
Suppose we have a page where the user submit a form with dynamic fields. For example, a gallery where the user can upload images for blog posts. Suppose that the requirements are a valid image, a valid caption, and html alt attribute as a placeholder for the image.
When using Laravel's validator, if the validation fails to more than one of these dynamic fields, then the same error message will repeat. For example, if the fields 4, 8, and 10 are all wrong, then it will appear three error messages that are the same.
The problem is that the user needs to know which fields are wrong. If the error messages contains the index of the wrong fields, it will be very convenient for the user to locate the error.
One workaround to this problem is to validate each dynamic field through a loop, so that in each iteration we add the field index to the error message, if any error message for the given field.
However, It would be much better if Laravel comes with built-in features to validate dynamic fields. When it comes to user-friendly platforms, with a lot of interactions, it's really convenient to have dynamic fields and validations that help the user.
If you think I wasn't clear enough, please point that out so that I can write a better feature request.
Thanks in advance :)
Beta Was this translation helpful? Give feedback.
All reactions