GoodValidate.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 GoodValidate extends Validate
  14. {
  15. protected $rule = [
  16. 'goods_name' => 'require|chsDash|length:2,50',
  17. 'sku' => 'require|chsDash|length:2,30',
  18. 'score' => 'require|number|length:1,10',
  19. 'stock' => 'require|number|length:1,10',
  20. 'cate_id' => 'require|number|length:1,10',
  21. 'albums' => 'require',
  22. ];
  23. protected $message = [
  24. 'goods_name.require' => '商品名称不为空',
  25. 'goods_name.*' => '商品名称格式不正确',
  26. 'score.require' => '商品兑换所需积分不为空',
  27. 'score.*' => '商品兑换所需积分格式错误',
  28. 'sku.require' => '商品库存不为空',
  29. 'sku.*' => '商品库存格式不正确',
  30. 'cate_id.require' => '商品分类不为空',
  31. 'cate_id.*' => '商品分类格式错误',
  32. 'albums.require' => '商品相册不为空',
  33. ];
  34. protected $field = [
  35. 'goods_name'=> '商品名称',
  36. 'score'=> '兑换所需积分',
  37. 'stock'=> '商品库存',
  38. 'cate_id'=> '商品分类',
  39. 'albums'=> '商品相册',
  40. ];
  41. protected $regex = [
  42. '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}$/',
  43. 'pwd'=> '/^[0-9a-zA-Z][0-9a-zA-Z\_\!\@\#\$\%\^\&\*\(\)]{2,19}/',
  44. ];
  45. protected $scene = [
  46. 'info' => ['goods_name','score','stock','cate_id','albums'],
  47. ];
  48. }