定制 raoul/php-validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

raoul/php-validator

最新稳定版本:V1.1.0

Composer 安装命令:

composer require raoul/php-validator

包简介

A simple validator for PHP

README 文档

README

How to install

composer require raoul/php-validator

Or

git clone https://github.com/RaoulvanWijk/Validator.git

How to use it?

To use my validator you can either instantiate the validator class

require_once __DIR__ .'/vendor/autoload.php';

use Raoul\Validator\Validator;

$validator = new Validator();

or create a new class that extends the base validator class

require_once __DIR__ .'/vendor/autoload.php';

use Raoul\Validator\Validator;

Class CustomValidator extends Validator
{
    public function rules()
    {
        return [
            // Your rules go here
        ];
    }

    public function messages()
    {
        return [
            // Your custom messages go here
        ];
    }
}

$validator = new CustomValidator();

And then call the validate method with the needed data

$validator->validate($data);

Specifying the rules

You have 2 options when specifying the rules when calling the validate method

$validator->validate($data, [
  'name' => ['required', 'min:4'],
  'email' => 'required|email'
  ]);

or in the rules() method

public function rules()
    {
        return [
            'name' => ['required', 'min:4'],
            'email' => 'required|email'
        ];
    }

Specifying custom validation messages

available validation rules

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固