PHP code example of cerbero / command-validator
1. Go to this page and download the library: Download cerbero/command-validator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cerbero / command-validator example snippets
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',
];
}
}
protected function messages(): array
{
return [
'min' => 'The minimum allowed :attribute is :min',
];
}
protected function attributes(): array
{
return [
'year' => 'year of birth',
];
}