Looking to hire Laravel developers? Try LaraJobs

laravel-rules maintained by anteris-dev

Description
Strongly typed Laravel validation attributes.
Author
Last update
2021/09/16 21:10 (dev-master)
License
Links
Downloads
1

Comments
comments powered by Disqus

Laravel Rules

Tests Style

This package adds classes that strongly type the Laravel Validation Rules. Currently these classes cannot be used with the default Laravel Validator, though that is our long-term goal.

Using an Attribute

Any of these validation rules may be used as an attribute on a class. If the validation rule accepts parameters, they will be type hinted on the class construct.

class SomeClass
{
    #[Max(255)]
    public string $firstName;
}

Retrieving the Compiled Rules

To retrieve the rule in Laravel format, call the getRules() method on any of the classes.

For example:

$rule = new Max(255);

// Returns: ['max:255']
$array = $rule->getRules();