2017 © Pedro Pelรกez
 

library command-validator

Validates Laravel console commands input.

image

cerbero/command-validator

Validates Laravel console commands input.

  • Thursday, September 29, 2016
  • by cerbero
  • Repository
  • 2 Watchers
  • 97 Stars
  • 15,719 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

โœ… Command Validator

Author ![PHP Version][ico-php] Laravel Version [Build Status][link-actions] ![Coverage Status][ico-scrutinizer] Quality Score ![PHPStan Level][ico-phpstan] ![Latest Version][ico-version] ![Software License][ico-license] PER Total Downloads, (*1)

Laravel package to validate the input of console commands., (*2)

๐Ÿ“ฆ Install

Via Composer:, (*3)

``` bash composer require cerbero/command-validator, (*4)


## ๐Ÿ”ฎ Usage To validate the input of our console commands, we can use the `ValidatesInput` trait and define the validation rules for our arguments and options in the `rules()` method: ```php use Illuminate\Console\Command; use Cerbero\CommandValidator\ValidatesInput; class SampleCommand extends Command { use ValidatesInput; protected function rules(): array { return [ 'some_argument' => 'integer|digits:4|min:2000', 'some_option' => 'string|max:2', ]; } }

The available rules are the same validation rules provided by Laravel. If we need custom validation, here is how we can define custom rules in Laravel., (*5)

Sometimes we may need to show custom messages or attributes for some validation errors. We can achieve that by overriding the methods messages() and attributes():, (*6)

protected function messages(): array
{
    return [
        'min' => 'The minimum allowed :attribute is :min',
    ];
}

protected function attributes(): array
{
    return [
        'year' => 'year of birth',
    ];
}

๐Ÿ“† Change log

Please see CHANGELOG for more information on what has changed recently., (*7)

๐Ÿงช Testing

bash composer test, (*8)

๐Ÿ’ž Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*9)

๐Ÿงฏ Security

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

๐Ÿ… Credits

โš–๏ธ License

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

The Versions

29/09 2016

dev-master

9999999-dev https://github.com/cerbero90/command-validator

Validates Laravel console commands input.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

validation console commands cerbero command-validator

29/09 2016

dev-develop

dev-develop https://github.com/cerbero90/command-validator

Validates Laravel console commands input.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

validation console commands cerbero command-validator

29/09 2016

1.0.1

1.0.1.0 https://github.com/cerbero90/command-validator

Validates Laravel console commands input.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

validation console commands cerbero command-validator

11/04 2016

1.0.0

1.0.0.0 https://github.com/cerbero90/command-validator

Validates Laravel console commands input.

  Sources   Download

MIT

The Requires

  • php ~5.5|~7.0

 

The Development Requires

validation console commands cerbero command-validator