No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Validate.php 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\facade;
  12. use think\Facade;
  13. /**
  14. * @see \think\Validate
  15. * @mixin \think\Validate
  16. * @method \think\Validate make(array $rules = [], array $message = [], array $field = []) static 创建一个验证器类
  17. * @method \think\Validate rule(mixed $name, mixed $rule = '') static 添加字段验证规则
  18. * @method void extend(string $type, mixed $callback = null) static 注册扩展验证(类型)规则
  19. * @method void setTypeMsg(mixed $type, string $msg = null) static 设置验证规则的默认提示信息
  20. * @method \think\Validate message(mixed $name, string $message = '') static 设置提示信息
  21. * @method \think\Validate scene(string $name) static 设置验证场景
  22. * @method bool hasScene(string $name) static 判断是否存在某个验证场景
  23. * @method \think\Validate batch(bool $batch = true) static 设置批量验证
  24. * @method \think\Validate only(array $fields) static 指定需要验证的字段列表
  25. * @method \think\Validate remove(mixed $field, mixed $rule = true) static 移除某个字段的验证规则
  26. * @method \think\Validate append(mixed $field, mixed $rule = null) static 追加某个字段的验证规则
  27. * @method bool confirm(mixed $value, mixed $rule, array $data = [], string $field = '') static 验证是否和某个字段的值一致
  28. * @method bool different(mixed $value, mixed $rule, array $data = []) static 验证是否和某个字段的值是否不同
  29. * @method bool egt(mixed $value, mixed $rule, array $data = []) static 验证是否大于等于某个值
  30. * @method bool gt(mixed $value, mixed $rule, array $data = []) static 验证是否大于某个值
  31. * @method bool elt(mixed $value, mixed $rule, array $data = []) static 验证是否小于等于某个值
  32. * @method bool lt(mixed $value, mixed $rule, array $data = []) static 验证是否小于某个值
  33. * @method bool eq(mixed $value, mixed $rule) static 验证是否等于某个值
  34. * @method bool must(mixed $value, mixed $rule) static 必须验证
  35. * @method bool is(mixed $value, mixed $rule, array $data = []) static 验证字段值是否为有效格式
  36. * @method bool ip(mixed $value, mixed $rule) static 验证是否有效IP
  37. * @method bool requireIf(mixed $value, mixed $rule) static 验证某个字段等于某个值的时候必须
  38. * @method bool requireCallback(mixed $value, mixed $rule,array $data) static 通过回调方法验证某个字段是否必须
  39. * @method bool requireWith(mixed $value, mixed $rule, array $data) static 验证某个字段有值的情况下必须
  40. * @method bool filter(mixed $value, mixed $rule) static 使用filter_var方式验证
  41. * @method bool in(mixed $value, mixed $rule) static 验证是否在范围内
  42. * @method bool notIn(mixed $value, mixed $rule) static 验证是否不在范围内
  43. * @method bool between(mixed $value, mixed $rule) static between验证数据
  44. * @method bool notBetween(mixed $value, mixed $rule) static 使用notbetween验证数据
  45. * @method bool length(mixed $value, mixed $rule) static 验证数据长度
  46. * @method bool max(mixed $value, mixed $rule) static 验证数据最大长度
  47. * @method bool min(mixed $value, mixed $rule) static 验证数据最小长度
  48. * @method bool after(mixed $value, mixed $rule) static 验证日期
  49. * @method bool before(mixed $value, mixed $rule) static 验证日期
  50. * @method bool expire(mixed $value, mixed $rule) static 验证有效期
  51. * @method bool allowIp(mixed $value, mixed $rule) static 验证IP许可
  52. * @method bool denyIp(mixed $value, mixed $rule) static 验证IP禁用
  53. * @method bool regex(mixed $value, mixed $rule) static 使用正则验证数据
  54. * @method bool token(mixed $value, mixed $rule) static 验证表单令牌
  55. * @method bool dateFormat(mixed $value, mixed $rule) static 验证时间和日期是否符合指定格式
  56. * @method bool unique(mixed $value, mixed $rule, array $data = [], string $field = '') static 验证是否唯一
  57. * @method bool check(array $data, mixed $rules = [], string $scene = '') static 数据自动验证
  58. * @method mixed getError(mixed $value, mixed $rule) static 获取错误信息
  59. */
  60. class Validate extends Facade
  61. {
  62. /**
  63. * 获取当前Facade对应类名(或者已经绑定的容器对象标识)
  64. * @access protected
  65. * @return string
  66. */
  67. protected static function getFacadeClass()
  68. {
  69. return 'validate';
  70. }
  71. }