AddressValidate.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 小夏 < 449134904@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\weixin\validate;
  12. use think\Validate;
  13. class AddressValidate extends Validate
  14. {
  15. protected $rule = [
  16. 'realname' => 'require|chsDash|length:2,6',
  17. 'mobile' => 'require|mobile|length:11,20',
  18. 'address' => 'require|length:2,150',
  19. 'is_default' => 'int',
  20. ];
  21. protected $message = [
  22. 'realname.require' => '收货人姓名不为空',
  23. 'realname.*' => '收货人姓名格式不正确',
  24. 'mobile.require' => '手机号码不为空',
  25. 'mobile.*' => '手机号码格式不正确',
  26. 'address.require' => '收货地址不为空',
  27. 'address.*' => '收货地址格式错误',
  28. ];
  29. /**
  30. * 验证字段描述
  31. * @var array
  32. */
  33. protected $field = [
  34. 'realname'=> '收货人姓名',
  35. 'mobile'=> '手机号码',
  36. 'address'=> '收货地址',
  37. ];
  38. protected $regex = [
  39. 'mobile'=> '/^((13[0-9])|(14[5,7])|(15[0-9])|(16[6-8])|(17[0,1,3,5-8])|(18[0-9])|(19[8,9]))\\d{8}$/',
  40. ];
  41. protected $scene = [
  42. 'info' => ['realname','mobile','address'],
  43. ];
  44. }