statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
32 stars 1 forks source link

Resolve validation inconsistency between Laravel and Statamic for `min` / `max` #766

Open RafaelKr opened 2 years ago

RafaelKr commented 2 years ago

I just came across this PR: https://github.com/statamic/cms/pull/4980

In the past min and max on Statamic file fields were validating the file COUNT whereas in Laravel they are validating the file SIZE.

To not break existing pages @jasonvarga decided to keep the behavior of min and max and add the new parameters min_filesize and max_filesize additionally. IMO this definitely makes sense for now, but should be changed with the next major release.

My suggestion would be:

If possible it would be great to have an automatic migration script which changes all existing validation fields.

Also the very similiar size validation should be checked to have the same behavior as in Laravel.

Laravel Validation Rules:

CC: @arthurperton

jasonvarga commented 2 years ago

What's actually being submitted is an array of IDs. The min/max rules are doing the right thing - validating the size of the array.

RafaelKr commented 2 years ago

Wow Jason, that's a fast answer right there! I think then it's correct, but the documentation for that is still missing, right? Was expecting it here: https://statamic.dev/validation

jasonvarga commented 2 years ago

Yes good point, we should definitely add it to that page.

RafaelKr commented 2 years ago

Should I open an issue in the docs repo to keep track of that?