Base.php 5.38 KB
Newer Older
庄钊鑫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
<?php
/**
 * Created by PhpStorm.
 * User: airon
 */

namespace app\common\validate;

use think\Validate;

class Base extends Validate
{
//    protected $regex = [
//        'mobile' => ''
//    ];
    protected $rule = [
        'page_index' => 'require|number|gt:0',
        'page_size' => 'require|number|gt:0',
        'invite_code'=>'length:6,11',
        'uuid' => 'require|length:32',
        'id' => 'require|number|gt:0',
        'content' => 'require|max:255',
        'mobile' => 'require|number|length:11|1\d{10}',
        'sms_type' => 'require|in:default,login,empty,must,bind,pay_password,pass,getback,oauth,reset,unbinding,register',
        'define_sms_type' => 'require|in:register,pass,bind,unbinding,reset,getback,set_pay,bind_card',
        'partner_sms_type' => 'require|in:pass,set_pay,bind_card',
        'sms_type_company' => 'require|in:pass,register,bind,getback,reset',
        'code' => 'require|max:6',
        'password' => 'require|min:6',
        'new_password' => 'require|min:6',
        'message_type' => 'require|in:con,chat,system',
        'province' => 'chsAlpha',
        'school_name' => 'chsAlpha',
        'city.json' => 'chsAlpha',
        'money' => 'require|number|egt:1',
        'pay_type' => 'require|in:alipay,wechat',
        'nya' => 'in:no,yes,all,,',
        'ny' => 'in:no,yes',
        'tf' => 'in:no,yes,0,1,true,false',
        'id_can_null' => 'number|gt:0',
        'keyword' => 'chsDash',
        'refresh_token' => 'require|length:32',
        'collect_type' => 'require|in:school,speciality',
        'oauth_type' => 'require|in:wechat,qq',
        'edit' => 'require|length:5',
        'type' => 'require|number|in:1,2',

        'name' => 'require|chsAlphaNum|length:0,64',
        'gender' => 'require|in:男,女',
        'birth' => 'require|chsAlphaNum|length:0,64',
        'avatar' => 'require|chsAlphaNum|length:0,64',
        'city' => 'require|chsAlphaNum|length:0,64',
        'key' => 'require',
    ];

//    protected $field = [
//        'mobile' => '手机号长度不符合要求 11'
//    ];

    protected $message = [
        'page_index' => '页码要大于0',
        'page_size' => '每页数量要大于0',
        'invite_code'=>'邀请码错误',
        'id' => 'id参数不符合',
        'content.require' => '内容不能为空',
        'content.max' => '超出最大长度',
        'mobile.number' => '手机号必须为数字',
        'mobile.length' => '手机号长度不符合要求11',
        'sms_type' => '短信类型错误',
        'code' => '验证码格式错误',
        'password.require' => '密码必须',
        'password.min' => '密码过短',
        'new_password.require' => '密码必须',
        'new_password.min' => '密码过短',
        'message_type' => '消息类型错误',
        'province' => '省份设置错误',
        'city.json' => '城市设置错误',
        'money' => '金额格式不正确',
        'pay_type' => '充值方式不正确',
        'nya' => '参数不正确',
        'ny' => '参数不正确',
        'id_can_null' => '参数不正确',
        'keyword' => '关键字不能带符号',
        'tf' => 'bool错误',
        'collect_type' => '收藏类型',
        'name' => '姓名',
        'gender' => '性别',
        'birth' => '出生年月',
        'avatar' => '头像',
        'city' => '所在地区',
        'edit' => '请输入正确信息',
        'key' => '请输入内容',
        'type' => '验证类型',
    ];

    protected $scene = [
        'page_index' => ['page_index'],
        'page_size' => ['page_size'],
        'page' => ['page_index', 'page_size'],
        'id' => ['id'],
        'uuid' => ['uuid'],
        'send_sms' => ['mobile', 'sms_type'],
        'reset' => ['password','sms_type','code'],
        'validate_sms' => ['mobile', 'sms_type','code','oauth_uuid'],
        'register' => ['mobile','password','sms_type','code','oauth_uuid','invite_code'],
        'update_pay_password' => ['password','new_password'],
        'company_register' => ['mobile','password','sms_type','code','oauth_uuid'],
        'email_validate' => ['email','password'],
        'email_verify' => ['email','code'],
        'mobile_validate' => ['mobile','password'],

        'sendPartnerSms' => ['mobile', 'sms_type_partner'],
        'validatePartnerCode' => ['mobile', 'sms_type_partner', 'code'],
        'app_login' => ['mobile','password','oauth_uuid'],
        'sendCompanySms' => ['mobile', 'define_sms_type'],
        'sendWebSms' => ['mobile', 'sms_type_company'],
        'validateCompanyCode' => ['mobile', 'sms_type_company', 'code'],
        'validateCode' => ['sms_type', 'code'],
        'validateWebCode' => ['sms_type', 'code','mobile'],
        'login' => ['mobile', 'code'],
        'bind' => ['mobile', 'code', 'password'],
        'nya' => ['nya'],
        'ny' => ['ny'],
        'id_can_null' => ['id_can_null'],
        'keyword' => ['keyword'],
        'tf' => ['tf'],
        'refresh_token' => ['refresh_token'],
        'feedback' => ['content'],
        'collect_list' => ['collect_type'],
        'cmsLogin' => ['name', 'password'],
        'admissionScore' => ['province','school_name'],
        'password' => ['password'],
        'batchCritical' => ['province'],
        'config' => ['key'],
        'invite_code'=>['invite_code'],

    ];

    public function getEnumRule($words)
    {
        $reg = implode('|', $words);
        $rule = "/^({$reg})$/";
        return $rule;
    }

}