CategoryValidate.php 738 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace app\admin\validate\intelligence;
  3. use think\Validate;
  4. class CategoryValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'category_name' => 'require|max:20',
  8. 'category_id' => 'require',
  9. 'category_pid' => 'require',
  10. ];
  11. protected $message = [
  12. 'category_name.require' => '分类名称不能为空',
  13. 'category_id.require' => '分类id不能为空',
  14. 'category_name.max' => '分类名称不能超过20字',
  15. 'category_pid' => '父级id不能为空',
  16. ];
  17. //场景
  18. protected $scene = [
  19. 'create' => ['category_name','category_pid'],
  20. 'update' => ['category_id'],
  21. 'info' => ['category_id']
  22. ];
  23. }