Need help with command-validator?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

cerbero90
158 Stars 9 Forks MIT License 72 Commits 0 Opened issues

Description

Validate Laravel console commands input.

Services available

!
?

Need anything else?

Contributors list

# 436,310
PHP
stream-...
json-pa...
Shell
31 commits
# 27,701
PHP
Shell
Redux
accessi...
1 commit

Command Validator

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

SensioLabsInsight

Laravel package to validate input in Artisan console commands.

Install

Via Composer

$ composer require cerbero/command-validator

Usage

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.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODEOFCONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.