Skip to content

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!

@godismyjudge95
Copy link
Contributor Author

Should I resubmit this as a PR against master for 6.x? It might make more sense since I am changing the Asset rules pretty heavily

@jasonvarga
Copy link
Member

jasonvarga commented Jul 21, 2025

That would be ideal. Thank you!

@jasonvarga jasonvarga closed this Jul 21, 2025
@godismyjudge95 godismyjudge95 deleted the asset-validation-error-per-asset branch July 23, 2025 17:28
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.

3 participants