Skip to main content

Module rules

Module rules 

Source
Expand description

内置验证规则 — 对齐 PHP think\Validate 类的内置规则方法

本模块实现 PHP think\Validate 类中除 require/must/is/regex 外的 所有内置规则方法。

§PHP 对齐

所有规则函数签名统一为:

fn rule(value: &Value, rule: &str, data: &Value, field: &str) -> bool

对齐 PHP $this->$type($value, $rule, $data, $field, $title) 调用。

§PHP 源码参考

  • e:\vue\test\鲜视达\server\vendor\topthink\framework\src\think\Validate.php
    • 第 717-728 行:confirm
    • 第 738-741 行:different
    • 第 751-754 行:egt
    • 第 764-767 行:gt
    • 第 777-780 行:elt
    • 第 790-793 行:lt
    • 第 802-805 行:eq
    • 第 926-933 行:activeUrl
    • 第 942-949 行:ip
    • 第 1109-1113 行:dateFormat
    • 第 1200-1209 行:requireIf
    • 第 1238-1247 行:requireWith
    • 第 1257-1266 行:requireWithout
    • 第 1275-1278 行:in
    • 第 1287-1290 行:notIn
    • 第 1299-1307 行:between
    • 第 1316-1324 行:notBetween
    • 第 1333-1351 行:length
    • 第 1360-1371 行:max
    • 第 1380-1391 行:min
    • 第 1401-1404 行:after
    • 第 1414-1417 行:before
    • 第 1427-1431 行:afterWith
    • 第 1441-1445 行:beforeWith
    • 第 1454-1471 行:expire
    • 第 1480-1483 行:allowIp
    • 第 1492-1495 行:denyIp

Functions§

active_url
验证是否为有效的域名或 IP — 对齐 PHP activeUrl
after
验证日期 — 对齐 PHP after
after_with
验证日期 — 对齐 PHP afterWith
allow_ip
验证 IP 许可 — 对齐 PHP allowIp
before
验证日期 — 对齐 PHP before
before_with
验证日期 — 对齐 PHP beforeWith
between
between 验证数据 — 对齐 PHP between
confirm
验证是否和某个字段的值是否一致 — 对齐 PHP confirm
date_format
验证时间和日期是否符合指定格式 — 对齐 PHP dateFormat
deny_ip
验证 IP 禁用 — 对齐 PHP denyIp
different
验证是否和某个字段的值是否不同 — 对齐 PHP different
egt
验证是否大于等于某个字段的值 — 对齐 PHP egt
elt
验证是否小于等于某个字段的值 — 对齐 PHP elt
eq
验证是否等于某个值 — 对齐 PHP eq
expire
验证有效期 — 对齐 PHP expire
gt
验证是否大于某个字段的值 — 对齐 PHP gt
in_rule
验证是否在范围内 — 对齐 PHP in
ip
验证是否有效 IP — 对齐 PHP ip
length
验证数据长度 — 对齐 PHP length
lt
验证是否小于某个字段的值 — 对齐 PHP lt
max
验证数据最大长度 — 对齐 PHP max
min
验证数据最小长度 — 对齐 PHP min
not_between
notBetween 验证数据 — 对齐 PHP notBetween
not_in
验证是否不在某个范围 — 对齐 PHP notIn
require_if
验证某个字段等于某个值的时候必须 — 对齐 PHP requireIf
require_with
验证某个字段有值的情况下必须 — 对齐 PHP requireWith
require_without
验证某个字段没有值的情况下必须 — 对齐 PHP requireWithout