cerbero/command-validator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cerbero/command-validator

最新稳定版本:3.0.0

Composer 安装命令:

composer require cerbero/command-validator

包简介

Laravel package to validate the input of console commands.

README 文档

README

Author PHP Version Laravel Version Build Status Coverage Status Quality Score PHPStan Level Latest Version Software License PER Total Downloads

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 andrea.marco.sartori@gmail.com instead of using the issue tracker.

🏅 Credits

⚖️ License

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

统计信息

  • 总下载量: 416.93k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 226
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 225
  • Watchers: 4
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-05