Main objective of this package is to provide a set of validation rules for Laravel in order to make it easier to write validation.
Validator::make($data, rules([
'email' => ['required', DbRules::string()], // ['required', 'string', 'max:255']
'smaller' => ['nullable', DbRules::string(20)], // ['nullable', 'string', 'max:20']
'birthday' => [DbRules::date()], // ['date_format:Y-m-d']
'tiny' => [DbRules::tinyInteger()], // ['integer', 'min:-128', 'max:127']
// ...
]));You can install the package via composer:
composer require soyhuce/laravel-validation-rulesDatabase related rules :
DbRules::stringDbRules::booleanDbRules::enumDbRules::dateDbRules::dateTimeDbRules::tinyIntegerDbRules::unsignedTinyIntegerDbRules::smallIntegerDbRules::unsignedSmallIntegerDbRules::mediumIntegerDbRules::unsignedMediumIntegerDbRules::integerDbRules::unsignedIntegerDbRules::bigIntegerDbRules::unsignedBigIntegerDbRules::smallIncrementsDbRules::mediumIncrementsDbRules::incrementsDbRules::bigIncrementsDbRules::floatDbRules::double
Miscellaneous rules :
MisRules::safePassword: GDPR/CNIL compatible password (at least 12 characters)MisRules::mediumPassword: GDPR/CNIL compatible password (at least 8 characters)
Rules extending CompoundRule cannot be used directly in Rule::when.
You will need to use ... in this case :
'commission_account' => Rule::when(
fn(Fluent $data) => $data->get('commission') !== null,
- ['required', DbRules::string()],
+ ['required', ...DbRules::string()],
'exclude'
),composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.