标签:长度 app ace pac php this namespace style mes
<?php namespace app\junyi\validate; use think\Validate; class User extends Validate { protected $rule = [ //验证规则,require验证是否存在, //length验证长度 //regex验证正则 ‘name‘ => ‘require|length:11|regex:/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/‘, ‘pass‘ => ‘require|length:6,18‘, ]; //验证失败的返回值,成功则无返回值 protected $message = [ ‘name.require‘ => ‘用户名不能为空‘, ‘name.regex‘ => ‘请输入正确的手机号码‘, ‘name.length‘ => ‘请输入正确的手机号码‘, ‘pass.require‘ => ‘密码不能为空‘, ‘pass.length‘ => ‘密码输入错误,请重新输入‘, ]; } //执行验证 $result = $this->validate($data,‘User‘); if(true !== $result){ // 验证失败 输出错误信息 return $result; }
标签:长度 app ace pac php this namespace style mes
原文地址:https://www.cnblogs.com/xiaogou/p/11663198.html