Skip to content
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

[5.x] Asset validation error per asset #11648

Open
wants to merge 5 commits into
base: 5.x
Choose a base branch
from

Conversation

godismyjudge95
Copy link
Contributor

We'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:

  • change the asset validation rules away from whole field validation rules to be single attribute Laravel rules instead
  • apply the validation rules (on the assets field only) to the items in the field instead of just the field itself
  • display the validation messages on each asset

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:

image


Let me know if this needs to be retargeted towards 6.x because it changes the rules so fundamentally and also modifies the translation

@godismyjudge95
Copy link
Contributor Author

Oops I didn't run the full test suite. I'll fix these real quick.

@edalzell
Copy link
Contributor

edalzell commented Apr 2, 2025

I love this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants