| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Http\Validator;
- class MemberPaymentValidator extends BaseValidator
- {
- // 当前模型所有验证规则
- public static $rules = [
- 'id' => 'required',
- 'type' => 'required',
- 'real_name' => 'required|min:2|max:20',
- 'bank_name' => 'required|max:30',
- 'branch_name' => 'required',
- 'bank_card'=> 'required',
- 'trade_quota'=> 'required',
- 'trade_num'=> 'required',
- ];
- // 当前模型所有错误提示信息
- public static $msgs = [
- 'required' => ':attribute不能为空',
- 'string' => ':attribute必须是字符串',
- 'min' => ':attribute长度不能小于:min位',
- 'max' => ':attribute长度不能大于:max位',
- 'exists' => ':attribute不存在',
- 'rule' => ':attribute格式不正确',
- 'mobile' => ':attribute格式不正确',
- 'email' => ':attribute格式不正确',
- 'username' => ':attribute格式不正确',
- ];
- // 当前模型所有验证字段
- public static $fields = [
- 'id' => 'ID',
- 'real_name' => '姓名',
- 'bank_name' => '银行名称',
- 'bank_card' => '银行卡号',
- 'branch_name' => '支行名称',
- 'type' => '类型',
- ];
- // 当前模型所有验证场景
- public static $scenes = [
- 'info'=> ['id'],
- 'add'=> ['real_name','bank_name','bank_card','branch_name','trade_quota','trade_num'],
- 'edit'=> ['id','real_name','bank_name','bank_card','branch_name','trade_quota','trade_num'],
- ];
- /**
- * 验证
- * @param $request
- * @param string $scene
- * @return int|mixed
- */
- public static function check($request, $scene=''){
- $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes);
- return $validator->checkParams($request, $scene);
- }
- }
|