Address.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zhengmingwei
  5. * Date: 2019/11/5
  6. * Time: 11:00 下午
  7. */
  8. namespace addons\unishop\validate;
  9. use think\Validate;
  10. class Address extends Validate
  11. {
  12. /**
  13. * 验证规则
  14. */
  15. protected $rule = [
  16. 'id' => 'require|integer',
  17. 'name' => 'require|max:30',
  18. 'mobile' => 'require|number|max:20',
  19. 'address' => 'require|max:255',
  20. 'is_default' => 'integer',
  21. 'province_id' => 'require',
  22. 'city_id' => 'require',
  23. 'area_id' => 'require',
  24. ];
  25. /**
  26. * 提示消息
  27. */
  28. protected $message = [
  29. 'name.required' => '名字必须填写',
  30. 'name.max' => '名字不能大于30字',
  31. 'mobile.required' => '电话号码必填',
  32. 'mobile.number' => '电话号码必须为数字',
  33. 'mobile.max' => '电话号码不能大于20字',
  34. 'address.required' => '地址不能为空',
  35. 'address.max' => '地址不能超过255字',
  36. 'is_default.integer' => '默认地址格式不对',
  37. 'province_id.require' => '请选择省份',
  38. 'city_id.require' => '请选择城市',
  39. 'area_id.require' => '请选择地区',
  40. ];
  41. /**
  42. * 验证场景
  43. */
  44. protected $scene = [
  45. 'add' => ['name', 'mobile', 'address', 'is_default', 'province_id', 'city_id', 'area_id'],
  46. 'edit' => ['id', 'name', 'mobile', 'address', 'is_default', 'province_id', 'city_id', 'area_id'],
  47. ];
  48. }