abetzi / validate-input
Simple laravel package to validate input in Artisan console commands
dev-master
2021-01-20 11:48 UTC
Requires
- php: ^7.0||^8.0
This package is auto-updated.
Last update: 2025-03-20 21:29:35 UTC
README
Simple laravel package to validate input in Artisan console command inputs.
Install
composer require abetzi/validate-input
Example
<?php
use Abetzi\ValidateInput\ValidateInput;
class ValidationOptionsCommand extends Command
{
use ValidateInput;
protected $signature = 'zend:opt
{name}
{--country=cs}
{--user=}
{--admin}
';
protected $description = 'Command description';
public function handle()
{
// do something useful
dump($this->validated);
return 0;
}
protected function rules(): array
{
return $rules = [
'name' => 'required',
'country' => 'required|in:cs,sk,pl,hu',
'user' => 'required|exists:users,id',
'admin' => 'boolean',
];
}
}