SystemAdminValidate.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\admin\setting;
  12. use think\Validate;
  13. class SystemAdminValidate extends Validate
  14. {
  15. /**
  16. * 定义验证规则
  17. * 格式:'字段名' => ['规则1','规则2'...]
  18. *
  19. * @var array
  20. */
  21. protected $rule = [
  22. 'account' => ['require', 'alphaDash', 'length:4,64'],
  23. 'conf_pwd' => 'require',
  24. 'pwd' => ['require', 'length:4,64'],
  25. 'real_name' => 'require',
  26. 'roles' => ['require', 'array'],
  27. 'phone' => ['require', 'mobile'],
  28. 'head_pic' => 'max:255',
  29. ];
  30. /**
  31. * 定义错误信息
  32. * 格式:'字段名.规则名' => '错误信息'
  33. *
  34. * @var array
  35. */
  36. protected $message = [
  37. 'account.require' => '请填写管理员账号',
  38. 'account.alphaDash' => '管理员账号应为数字和字母',
  39. 'account.length' => '管理员账号长度4-64位字符',
  40. 'conf_pwd.require' => '请输入确认密码',
  41. 'pwd.require' => '请输入密码',
  42. 'pwd.length' => '密码长度4-64位字符',
  43. 'real_name.require' => '请输管理员姓名',
  44. 'roles.require' => '请选择管理员身份',
  45. 'roles.array' => '身份必须为数组',
  46. 'phone.require' => '请填写管理员电话',
  47. 'phone.mobile' => '电话格式不正确',
  48. 'head_pic.max' => '头像不能超过255个字符',
  49. ];
  50. protected $scene = [
  51. 'get' => ['account', 'pwd'],
  52. 'update' => ['account', 'roles', 'real_name', 'phone'],
  53. 'save' => ['account', 'pwd', 'conf_pwd', 'roles', 'real_name', 'phone'],
  54. 'supplier_save' => ['account', 'pwd', 'conf_pwd', 'real_name', 'phone', 'head_pic'],
  55. 'supplier_update' => ['account', 'real_name', 'phone', 'head_pic'],
  56. ];
  57. }