cerbero90/command-validator
Tentang
✅ Laravel package to validate the input of console commands.
Pengembangan web dan aplikasiPertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- 0
- dalam 15 hari
- +1
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
Asli✅ Command Validator
Laravel package to validate the input of console commands.
📦 Install
Via Composer:
composer require cerbero/command-validator
🔮 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:
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.
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():
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.
🧪 Testing
composer test
💞 Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT 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.
Jelajahi proyek terkait
Memuat…