Open SaeedDev94 opened 3 years ago
This will get really messy with options for rules:
$request->validate([
'field' => [Rule::required, Rule::max.':255', Rule::email.':rfc,dns']
]);
If you are using PHPStorm the Laravel Idea fully supports validations strings with auto-suggest.
For rules with arguments we can use static methods
Like: Rule::unique($table, $column = 'NULL')
that already exists
Laravel idea that you mentioned does not suggest in all cases, also it's a paid plugin
$request->validate([
'field' => [Rule::required, Rule::max(255), Rule::email(['rfc', 'dns'])]
]);
You can see this pattern in angular ReactiveFormsModule:
age = new FormControl(10, [Validators.required, Validators.min(18)]);
(For example Rule::min($value)
can simply generate validation string: min:value
)
Hi, It would be better if we create some const in
Illuminate\Validation\Rule
class to suggest rules in IDE Dev must write the exact rule name or install plugin to suggest rules, i think this way is more dev friendly:Then in controller:
By typing
Rule::
dev can see all available validation rules with description What do you think?