MerchantUpdateValidate.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\validate\merchant;
  3. use think\Validate;
  4. class MerchantUpdateValidate extends Validate
  5. {
  6. protected $failException = true;
  7. protected $rule = [
  8. 'mer_info|店铺简介' => 'require|max:200',
  9. 'service_phone|服务电话' => 'require|isPhone',
  10. 'mer_avatar|店铺头像' => 'require|max:128',
  11. 'mer_banner|店铺banner' => 'require|max:128',
  12. 'mer_certificate|店铺资质' => 'require|array|min:1',
  13. 'mini_banner|店铺街banner' => 'max:128',
  14. 'mer_keyword|店铺关键字' => 'max:128',
  15. 'mer_address|店铺地址' => 'require|max:128',
  16. 'long|店铺经度' => 'max:24',
  17. 'lat|店铺纬度' => 'max:24',
  18. 'mer_state|是否开启' => 'require|in:0,1',
  19. ];
  20. protected function isPhone($val)
  21. {
  22. $res = preg_match('/^((\+86|\+86\-)|(86|86\-)|(0086|0086\-))?1\d{10}$|^(0\d{2,3}\-)?([2-9]\d{6,7})+(\-\d{1,6})?$/', $val);
  23. if ($res) return true;
  24. return '服务电话格式有误';
  25. }
  26. }