| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Http\Validator;
- class MemberBankValidator extends BaseValidator
- {
- // 当前模型所有验证规则
- public static $rules = [
- 'id' => 'required',
- 'mobile'=> 'required|mobile',
- 'realname' => 'required|min:2|max:30',
- 'bank_name' => 'required|min:2|max:30',
- 'bank_num' => 'required|min:6|max:30',
- ];
- // 当前模型所有错误提示信息
- public static $msgs = [
- 'required' => ':attribute不能为空',
- 'string' => ':attribute必须是字符串',
- 'min' => ':attribute长度不能小于:min位',
- 'max' => ':attribute长度不能大于:max位',
- 'exists' => ':attribute不存在',
- 'rule' => ':attribute格式不正确',
- ];
- // 当前模型所有验证字段
- public static $fields = [
- 'id' => 'ID',
- 'realname' => '姓名',
- 'mobile' => '手机号',
- 'bank_name' => '开户行/支行',
- 'bank_num' => '银行卡号',
- ];
- // 当前模型所有验证场景
- public static $scenes = [
- 'info'=> ['id'],
- 'save'=> ['realname','bank_name','bank_num'],
- 'del'=> ['id'],
- ];
- /**
- * 验证
- * @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);
- }
- }
|