-
-
Notifications
You must be signed in to change notification settings - Fork 586
[6.x] Asset validation error per asset #11988
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
base: master
Are you sure you want to change the base?
[6.x] Asset validation error per asset #11988
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind please keeping the scope of this PR to showing the individual asset validation errors?
Please separate the changes to the rules themselves into a separate PR. The rules we're using are based on native Laravel validation.
I believe those changes are necessary to get the assets to individually validate. The way the rules were set up currently I could not get separate validation messages for each asset. I may have overlooked a way to do so; I will double check. |
|
Sorry I mean, the classes can change if they need to, but the logic/messages shouldn't. e.g. The dimensions rule should continue to just say "invalid image dimensions" - not give specific "must have a ratio of x" etc messages. |
Oh ok, yeah I can revert that |
|
Uh... I think these tests failing are unrelated? I just merged from master and now it's failing. 🫠 |
|
Don't worry about failing tests from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I think I now have all of the whole field validation rules listed here now: if (Str::of($rule)->before(':')->is(['array', 'required', 'nullable', 'max', 'min'])) { |

This is a 6.x port of this PR - #11648
It resolves:
regexandnot_regexdon't work with Assets (arrays) #6246We've had a number of clients contact us with confusion about the validation errors that are shown when using asset validation rules. Specifically things like the dimensions rule or mime type cause confusion when it just gives a generic "invalid data" error instead of telling you what asset is invalid and why.
This PR solves that by doing three things:
In theory everything should work the same - I only had to change a single test which called the
->passes()method directly on the dimension rule.Here is a what it looks like with invalid assets:
The asset grid does not appear to be styled for me, so I assume that is still under development. I wanted to get these changes PR'd though so whoever is working on that can incorporate them into it.
Update: the UI looks much better now.