Laravel-Backpack / devtools-issues

Bug reports and feature requests for our closed-source DevTools package
4 stars 1 forks source link

[Feature Request] Make validation rule match field size #31

Closed Polfo closed 2 years ago

Polfo commented 3 years ago

Feature Request

What's the feature you think DevTools should have?

When I define a string with a certain length image the corresponding request rule should reflect this

return [
    'str10' => 'required|string',
];

should be

return [
    'str10' => 'required|string|max:10',
];

If not, I face

Illuminate\Database\QueryException
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'str10' at row 1 (SQL: update `table_name` set `str10` = 123456789, `table_name`.`updated_at` = 2021-12-03 21:19:34 where `id` = 2)

How often do you see yourself using this feature, if implemented?

Every time I set the length of a field

tabacitu commented 3 years ago

I agree. This is a current limitation of an underlying library (Blueprint). We plan to remove Blueprint and code our own implementation - when we do that we'll also add min and max validation rules based on DB column restrictions 👍

promatik commented 2 years ago

Thank you for the report @Polfo!

I've already submitted a PR to fix this issue, it will be available in the next DevTools version 🙌