2017 © Pedro Peláez
 

library think-validate

分离thinkphp5的validate类

image

sgb/think-validate

分离thinkphp5的validate类

  • Tuesday, April 24, 2018
  • by 路上
  • Repository
  • 1 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

thinkphp5-validate

使用tp5过程中发现validate还不错故将他剥离开来

注意 由于只是用到了validate 代码里面有些小调整 去掉了多语言功能, (*1)

第一步引入

第二步

    //待验证的控制器
    include_once "../vendor/autoload.php";
    include_once "./Validate/UserValidate.php";
    $user = new \Validate\UserValidate();
    $param = "";
    if(!$user->scene('ret')->check( $param ))
    {
        $user->getError();
    }
    //Validate/UserValidate.php
    namespace Validate;

    use think5\Validate;

    class UserValidate extends Validate {

        protected $rule =   [
            'name'  => 'require|max:25',
            'age'   => 'number|between:1,120',
        ];

        protected $message  =   [
            'name.require' => '名称必须',
            'name.max'     => '名称最多不能超过25个字符',
            'age.number'   => '年龄必须是数字',
            'age.between'  => '年龄只能在1-120之间',
            'email'        => '邮箱格式错误',
        ];

        protected $scene = [
            //流标场景
            'ret' => ['name','age','email'],
        ];
    }

具体的验证规则请移步至thinkphp5 thinkphp5-规则验证 , (*2)

The Versions

24/04 2018

dev-master

9999999-dev

分离thinkphp5的validate类

  Sources   Download

The Development Requires

by carter911

24/04 2018

1.1.4

1.1.4.0

分离thinkphp5的validate类

  Sources   Download

The Development Requires

by carter911

18/04 2018

1.1

1.1.0.0

分离thinkphp5的validate类

  Sources   Download

The Development Requires

by carter911

18/04 2018

1.1.1

1.1.1.0

分离thinkphp5的validate类

  Sources   Download

The Development Requires

by carter911