StoreProductReplyValidate.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\admin\product;
  12. use think\Validate;
  13. class StoreProductReplyValidate extends Validate
  14. {
  15. /**
  16. * 定义验证规则
  17. * 格式:'字段名' => ['规则1','规则2'...]
  18. *
  19. * @var array
  20. */
  21. protected $rule = [
  22. 'product_id' => 'require',
  23. 'avatar' => 'require',
  24. 'nickname' => 'require',
  25. 'comment' => 'require',
  26. 'product_score' => ['require','In:1,2,3,4,5'],
  27. 'service_score' => ['require','In:1,2,3,4,5'],
  28. ];
  29. /**
  30. * 定义错误信息
  31. * 格式:'字段名.规则名' => '错误信息'
  32. *
  33. * @var array
  34. */
  35. protected $message = [
  36. 'product_id.require' => '请选择商品',
  37. 'avatar.require' => '请选择用户头像',
  38. 'nickname.require' => '请填写用户昵称',
  39. 'comment.require' => '请填写评论内容',
  40. 'product_score.require' => '请选择商品分数',
  41. 'service_score.require' => '请选择服务分数',
  42. 'product_score.In' => '商品分数必须是1-5之间的整数',
  43. 'service_score.In' => '服务分数必须是1-5之间的整数',
  44. ];
  45. protected $scene = [
  46. 'save' => ['product_id', 'nickname', 'comment', 'avatar', 'product_score', 'service_score'],
  47. ];
  48. }