brokeyourbike / enum-validation
PHP 8.1 enum validation rules for Laravel
Fund package maintenance!
brokeyourbike
Open Collective
Requires
- php: ^8.1
- illuminate/contracts: ^8|^9
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- orchestra/testbench: ^6.21
- phpunit/phpunit: ^9.5
README
PHP 8.1 enum validation rules for Laravel
Installation
composer require brokeyourbike/enum-validation
Usage
use Illuminate\Foundation\Http\FormRequest; use BrokeYourBike\EnumValidation\IsValidEnum; enum DrinkEnum: string { case WINE = 'wine'; case VODKA = 'vodka'; } class ExampleRequest extends FormRequest { public function rules() { return [ 'drink' => [ 'required', 'string', new IsValidEnum(DrinkEnum::class), ], ]; } }
Authors
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk