Address.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\api\validate;
  3. use think\Validate;
  4. class Address extends Validate
  5. {
  6. /**
  7. * 验证规则
  8. */
  9. protected $rule = [
  10. 'receiver' => 'require|length:1,30',
  11. 'mobile' => 'require|mobile',
  12. 'address' => 'require|length:1,255',
  13. 'area_id' => 'require|integer|gt:0',
  14. 'is_default' => 'in:0,1',
  15. ];
  16. /**
  17. * 提示消息
  18. */
  19. protected $message = [
  20. 'receiver.require' => '收货人姓名不能为空',
  21. 'receiver.length' => '收货人姓名长度不能超过30个字符',
  22. 'mobile.require' => '手机号不能为空',
  23. 'mobile.mobile' => '手机号格式不正确',
  24. 'address.require' => '详细地址不能为空',
  25. 'address.length' => '详细地址长度不能超过255个字符',
  26. 'area_id.require' => '请选择所在地区',
  27. 'area_id.integer' => '地区ID必须为整数',
  28. 'area_id.gt' => '地区ID必须大于0',
  29. 'is_default.in' => '默认地址参数错误',
  30. ];
  31. /**
  32. * 验证场景
  33. */
  34. protected $scene = [
  35. 'add' => ['receiver', 'mobile', 'address', 'area_id', 'is_default'],
  36. 'edit' => ['receiver', 'mobile', 'address', 'area_id', 'is_default'],
  37. ];
  38. }