UserValidate.php 746 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\validate\admin;
  3. use think\Validate;
  4. class UserValidate extends Validate
  5. {
  6. protected $failException = true;
  7. protected $rule = [
  8. 'real_name|真实姓名' => 'max:25',
  9. 'phone|手机号' => 'isPhone',
  10. 'birthday|生日' => 'dateFormat:Y-m-d',
  11. 'card_id|身份证' => 'length:18',
  12. 'addres|用户地址' => 'max:64',
  13. 'mark|备注' => 'max:200',
  14. 'group_id|分组' => 'integer',
  15. 'label_id|标签' => 'array',
  16. 'is_promoter|推广人' => 'in:0,1'
  17. ];
  18. protected function isPhone($val)
  19. {
  20. if (!preg_match('/^1[3456789]{1}\d{9}$/', $val))
  21. return '请输入正确的手机号';
  22. else
  23. return true;
  24. }
  25. }