Config.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 海豚PHP框架 [ DolphinPHP ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://dolphinphp.com
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\validate;
  12. use think\Validate;
  13. /**
  14. * 配置验证器
  15. * @package app\admin\validate
  16. * @author 蔡伟明 <314013107@qq.com>
  17. */
  18. class Config extends Validate
  19. {
  20. // 定义验证规则
  21. protected $rule = [
  22. 'group|配置分组' => 'require',
  23. 'type|配置类型' => 'require',
  24. 'name|配置名称' => 'require|regex:^[a-zA-Z]\w{0,39}$|unique:admin_config',
  25. 'title|配置标题' => 'require',
  26. ];
  27. // 定义验证提示
  28. protected $message = [
  29. 'name.regex' => '配置名称由字母和下划线组成',
  30. ];
  31. // 定义场景,供快捷编辑时验证
  32. protected $scene = [
  33. 'name' => ['name'],
  34. 'title' => ['title'],
  35. ];
  36. }