Channel.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 小夏 < 449134904@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\validate;
  12. use app\common\library\ValidateExtend;
  13. class Channel extends ValidateExtend
  14. {
  15. protected $rule = [
  16. 'username' => 'require|max:30',
  17. 'password' => 'require|length:6,30|passwordRule',
  18. 'repassword' => 'require|length:6,30',
  19. 'pay_password' => 'require|length:6|number',
  20. 'pay_repassword' => 'require|length:6',
  21. 'login_check' => 'require',
  22. 'status' => 'require',
  23. 'mobile' => 'is:mobile',
  24. 'beizhu' => 'max:20'
  25. ];
  26. protected $message = [
  27. 'username.require' => '渠道名称不能为空',
  28. 'username.max' => '渠道名称不能超过30个字符',
  29. 'password.require' => '密码不能为空',
  30. 'password.length' => '密码长度为 6 - 30',
  31. 'password.passwordRule' => '密码为数字和字母的组合',
  32. 'repassword.require' => '密码不能为空',
  33. 'repassword.length' => '新密码长度为 6 - 30',
  34. 'pay_password.require' => '支付密码不能为空',
  35. 'pay_password.length' => '支付密码长度为 6',
  36. 'pay_password.number' => '支付密码为数字',
  37. 'pay_repassword.require' => '支付密码不能为空',
  38. 'pay_repassword.length' => '支付密码长度为 6',
  39. 'login_check.require' => '登录校验不能为空',
  40. 'status.require' => '状态不能为空',
  41. 'mobile.is' => '请输入正确的手机号',
  42. 'beizhu.max' => '备注不能超过20个字符'
  43. ];
  44. protected $scene = [
  45. 'add' => ['username', 'password', 'repassword', 'login_check', 'status', 'mobile','beizhu'],
  46. 'edit' => ['login_check', 'status', 'mobile','beizhu'],
  47. 'password' => ['password', 'repassword'],
  48. 'pay_password' => ['pay_repassword', 'pay_password']
  49. ];
  50. /**
  51. * 密码为数字和字母的组合
  52. *
  53. * @param $value
  54. * @return bool
  55. */
  56. public function passwordRule($value)
  57. {
  58. if (empty($value)) {
  59. return false;
  60. }
  61. return preg_match('/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9a-zA-Z]+$/', $value) == 1;
  62. }
  63. }