UserValidate.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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;
  12. use think\Validate;
  13. class UserValidate extends Validate
  14. {
  15. protected $failException = true;
  16. protected $rule = [
  17. 'real_name|真实姓名' => 'max:25',
  18. 'phone|手机号' => 'isPhone',
  19. 'birthday|生日' => 'dateFormat:Y-m-d',
  20. 'card_id|身份证' => 'length:18',
  21. 'addres|用户地址' => 'max:64',
  22. 'mark|备注' => 'max:200',
  23. 'group_id|分组' => 'integer',
  24. 'label_id|标签' => 'array',
  25. 'is_promoter|推广人' => 'in:0,1'
  26. ];
  27. protected function isPhone($val)
  28. {
  29. if (!preg_match('/^1[3456789]{1}\d{9}$/', $val))
  30. return '请输入正确的手机号';
  31. else
  32. return true;
  33. }
  34. }