Simple and lightweight package to let your Laravel console commands validate the input they receive.
From the root of your project run the following command in the terminal:
composer require cerbero/command-validator
Let the commands of which you want to validate input use this package trait and define the rules() method:
class Example extends Command
public function rules()
'year' => 'digits:4|min:2000'
Both arguments and options can be validated, set their name as keys (no dashes for options) and their rules as values in the array returned by the rules() method.
The rules available are the Laravel default ones and of course you can extend them by specifying your custom rules.
You may also want to indicate custom messages and attributes for some validation errors, in this case just override the methods messages() and attributes():
public function messages()
'min' => 'The minimum allowed :attribute is :min'
public function attributes()
'year' => 'year of birth'
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email email@example.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.