bbprojectnet / laravel-rules
为Laravel提供额外的规则类。
1.0.1
2023-05-16 16:39 UTC
Requires
- php: >=8.1.0
- illuminate/contracts: ^9.0|^10.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
此包为Laravel提供了一些额外的验证规则。
要求
- PHP 8.1 及以上
- Laravel 9 或 10
安装
使用以下命令通过composer安装此包
composer require bbprojectnet/laravel-rules
规则
Base64
检查给定的字符串是否为base 64编码的字符串。
return [ 'attribute' => [new Base64()], ];
EnumCase
检查给定的字符串是否是枚举值之一。
return [ 'attribute' => [new EnumCase(Color::class)], // any enum case 'attribute' => [new EnumCase([Color::Red, Color::Blue])], // selected enum cases ];
Extension
检查给定的文件名字符串是否具有允许的扩展名之一。
return [ 'attribute' => [new Extension(['jpg', 'png', 'gif'])], ];
ManyOf
检查给定的字符串(例如,通过逗号分隔)中的值是否满足指定的规则。
$rule = new Extension(['jpg', 'png']); return [ 'attribute' => [new ManyOf($rule)], 'attribute' => [(new ManyOf($rule))->delimeter('|')], // with custom delimeter ];
许可证
Laravel规则包是开源软件,许可协议为MIT。