WechatNewsValidate.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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;
  12. use think\Validate;
  13. class WechatNewsValidate extends Validate
  14. {
  15. protected $failException = true;
  16. protected $rule = [
  17. 'data' => 'array|checkArray',
  18. // 'title|标题' => 'require',
  19. // 'author|作者' => 'require',
  20. // 'synopsis|摘要' => 'require',
  21. // 'image_input|图片' => 'require',
  22. // 'content|内容' => 'require',
  23. ];
  24. protected function checkArray($value,$rule,$data = [])
  25. {
  26. foreach ($value as $v) {
  27. if(empty($v['title']))
  28. return '标题不能为空';
  29. if(empty($v['author']))
  30. return '作者不能为空';
  31. if(empty($v['synopsis']))
  32. return '摘要不能为空';
  33. if(empty($v['image_input']))
  34. return '图片不能为空';
  35. if(empty($v['content']))
  36. return '内容不能为空';
  37. }
  38. return true;
  39. }
  40. }