标签:== ali 之间 手记 dump 定义 span 图片 mail
# 创建验证器 php think make:validate 模块名/验证器名(首字母大写) # 验证器 namespace app\index\validate; use think\Validate; class User extends Validate { protected $rule = [ ‘name‘ => ‘require|max:25‘, ‘age‘ => ‘number|between:1,120‘, ‘email‘ => ‘email‘, ]; protected $message = [ ‘name.require‘ => ‘名称必须‘, ‘name.max‘ => ‘名称最多不能超过25个字符‘, ‘age.number‘ => ‘年龄必须是数字‘, ‘age.between‘ => ‘年龄只能在1-120之间‘, ‘email‘ => ‘邮箱格式错误‘, ]; } # 控制器 $ret = $this->validate($request->post(),User::class); if (true !== $ret){ dump($ret); }
自定义规则的写法
验证器类
控制器
标签:== ali 之间 手记 dump 定义 span 图片 mail
原文地址:https://www.cnblogs.com/somethingWithiOS/p/11968268.html