Article.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\article;
  12. use think\Validate;
  13. /**
  14. * Class Article
  15. * @package app\validate\article
  16. */
  17. class Article extends Validate
  18. {
  19. //用户名或密码的规范可能是从数据库中获取的
  20. protected $rule = [
  21. 'title' => 'require|max:20',
  22. 'intro' => 'max:50',
  23. 'summary' => 'max:50',
  24. 'image' => 'max:255',
  25. 'author' => 'max:20',
  26. 'is_show' => 'number|between:0,1',
  27. 'sort' => 'number|between:0,10000',
  28. 'category_id' => 'number|require',
  29. 'content' => 'require',
  30. ];
  31. protected $message = [
  32. 'title.require' => 'validate_article.title_require',
  33. 'title.max' => 'validate_article.title_max',
  34. 'intro.max' => 'validate_article.intro_max',
  35. 'summary.max' => 'validate_article.summary_max',
  36. 'image.max' => 'validate_article.image_max',
  37. 'author.max' => 'validate_article.author_max',
  38. 'is_show.number' => 'validate_article.is_show_number',
  39. 'is_show.between' => 'validate_article.is_show_between',
  40. 'sort.number' => 'validate_article.sort_number',
  41. 'sort.between' => 'validate_article.sort_between',
  42. 'category_id.require' => 'validate_article.category_id_require',
  43. 'category_id.number' => 'validate_article.category_id_number',
  44. 'content.require' => 'validate_article.content_require',
  45. ];
  46. protected $scene = [
  47. 'add' => ['title', 'intro', 'summary', 'image', 'author', 'is_show', 'sort', 'content', 'category_id'],
  48. 'edit' => ['title', 'intro', 'summary', 'image', 'author', 'is_show', 'sort', 'content', 'category_id'],
  49. ];
  50. }