ShopAddress.php 812 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. class ShopAddress extends Validate
  5. {
  6. /**
  7. * 定义验证规则
  8. * 格式:'字段名' => ['规则1','规则2'...]
  9. *
  10. * @var array
  11. */
  12. protected $rule = [
  13. 'name|收货人' => 'require|length:1,20',
  14. 'phone|联系电话' => 'require|checkPhone',
  15. // 'building|楼号' => 'require',
  16. // 'unit|单元' => 'require',
  17. 'content|详细地址' => 'require',
  18. ];
  19. /**
  20. * 定义错误信息
  21. * 格式:'字段名.规则名' => '错误信息'
  22. *
  23. * @var array
  24. */
  25. protected $message = [
  26. 'phone.checkPhone'=>'请输入正确的联系电话'
  27. ];
  28. protected function checkPhone($value){
  29. return !check_mobile($value)?false:true;
  30. }
  31. }