Validate Laravel console commands input.

Fund package maintenance!

Installs: 256 093

Dependents: 1

Suggesters: 0

Security: 0

Stars: 160

Watchers: 5

Forks: 11

Open Issues: 0

2.5.0 2021-04-24 02:31 UTC

This package is auto-updated.

Last update: 2024-05-09 13:27:09 UTC


Author PHP Version Laravel Version Build Status Coverage Status Quality Score Latest Version Software License PSR-12 Total Downloads


Laravel package to validate input in Artisan console commands.


Via Composer

$ composer require cerbero/command-validator


This package merely consists in the ValidatesInput trait that Artisan commands can use to define their own validation rules for arguments and options in the rules() method:

use Illuminate\Console\Command;
use Cerbero\CommandValidator\ValidatesInput;

class SampleCommand extends Command
    use ValidatesInput;

    protected function rules()
        return [
            'year' => 'integer|digits:4|min:2000',
            'some_option' => 'string|max:2',

The available rules are the same validation rules provided by Laravel. If you need custom validation, please have a look at how to define custom rules.

Sometimes you may need to show custom messages or attributes for some validation errors. You can achieve that by overriding the methods messages() and attributes():

protected function messages()
    return [
        'min' => 'The minimum allowed :attribute is :min'

protected function attributes()
    return [
        'year' => 'year of birth'

Change log

Please see CHANGELOG for more information on what has changed recently.


$ composer test


Please see CONTRIBUTING and CODE_OF_CONDUCT for details.


If you discover any security related issues, please email andrea.marco.sartori@gmail.com instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.