Card.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\api\validate;
  3. use think\Validate;
  4. class Card extends Validate
  5. {
  6. // 验证规则
  7. protected $rule = [
  8. 'company_name' => 'require|chsDash|max:30',
  9. 'department' => 'require|chsDash|max:20',
  10. 'name' => 'require|chsAlphaNum|max:10',
  11. 'position' => 'chsDash|max:20',
  12. 'phone' => 'mobile',
  13. 'wx' => 'max:20',
  14. 'email' => 'email',
  15. 'brief' => 'max:255',
  16. ];
  17. // 验证消息
  18. protected $message = [
  19. 'company_name.require' => '请填写公司名称',
  20. 'company_name.chsDash' => '公司名称格式错误',
  21. 'company_name.max' => '公司名称20字以内',
  22. 'department.require' => '请填写部门',
  23. 'department.chsDash' => '部门格式错误',
  24. 'department.max' => '部门限制20字以内',
  25. 'name.require' => '请填写姓名',
  26. 'name.chsDash' => '姓名格式错误',
  27. 'name.max' => '姓名限制10字以内',
  28. 'position.chsDash' => '职务格式错误',
  29. 'position.max' => '职务限制20字以内',
  30. 'phone.mobile' => '手机号格式错误',
  31. 'wx.max' => '微信号超出长度',
  32. 'email.email' => '邮箱格式错误',
  33. 'brief.max' => '个人简介超出长度',
  34. ];
  35. // 验证场景
  36. protected $scene = [
  37. 'save' => ['company_name', 'department', 'name', 'position', 'phone', 'wx', 'email', 'brief'],
  38. ];
  39. }