企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
>[danger] 验证器类成员 ```php <?php declare (strict_types = 1); namespace app\validate; use think\Validate; class User extends Validate { /** * 定义验证规则 * 格式:'字段名' => ['规则1','规则2'...] * * @var array */ protected $rule = []; /** * 定义错误信息 * 格式:'字段名.规则名' => '错误信息' * * @var array */ protected $message = []; /** * 定义验证场景 * 格式:'场景名' => '字段名' * * @var array */ protected $scene = [ 'add' => ['title'], ]; // edit 验证场景定义 public function sceneEdit() { return $this->only(['name','age']) ->append('name', 'min:5') ->remove('age', 'between') ->append('age', 'require|max:100'); } } ```