mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-10 08:32:48 +08:00
修正traits\model\Auto
This commit is contained in:
@@ -74,7 +74,7 @@ class Validate
|
||||
// 不满足自动验证条件
|
||||
continue;
|
||||
}
|
||||
$result = true;
|
||||
|
||||
if ($val instanceof \Closure) {
|
||||
// 匿名函数验证 支持传入当前字段和所有字段两个数据
|
||||
$result = self::callback($value, $val, $data);
|
||||
@@ -85,6 +85,7 @@ class Validate
|
||||
// 验证字段规则
|
||||
$result = self::checkItem($value, $val, $data);
|
||||
}
|
||||
|
||||
if (true !== $result) {
|
||||
// 没有返回true 则表示验证失败
|
||||
if (!empty($options['patch'])) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace traits\model;
|
||||
|
||||
use think\Config;
|
||||
use think\Lang;
|
||||
|
||||
trait Auto
|
||||
@@ -193,7 +194,7 @@ trait Auto
|
||||
$auto[3] = 'string';
|
||||
}
|
||||
switch (trim($auto[3])) {
|
||||
case 'function':// 使用函数进行填充 字段的值作为参数
|
||||
case 'function': // 使用函数进行填充 字段的值作为参数
|
||||
case 'callback': // 使用回调方法
|
||||
$args = isset($auto[4]) ? (array) $auto[4] : [];
|
||||
if (is_string($auto[0]) && strpos($auto[0], ',')) {
|
||||
@@ -356,7 +357,7 @@ trait Auto
|
||||
protected function _validationFieldItem($data, $val)
|
||||
{
|
||||
switch (strtolower(trim($val[4]))) {
|
||||
case 'function':// 使用函数进行验证
|
||||
case 'function': // 使用函数进行验证
|
||||
case 'callback': // 调用方法进行验证
|
||||
$args = isset($val[6]) ? (array) $val[6] : [];
|
||||
if (is_string($val[0]) && strpos($val[0], ',')) {
|
||||
@@ -416,11 +417,11 @@ trait Auto
|
||||
{
|
||||
$type = strtolower(trim($type));
|
||||
switch ($type) {
|
||||
case 'in':// 验证是否在某个指定范围之内 逗号分隔字符串或者数组
|
||||
case 'in': // 验证是否在某个指定范围之内 逗号分隔字符串或者数组
|
||||
case 'notin':
|
||||
$range = is_array($rule) ? $rule : explode(',', $rule);
|
||||
return 'in' == $type ? in_array($value, $range) : !in_array($value, $range);
|
||||
case 'between':// 验证是否在某个范围
|
||||
case 'between': // 验证是否在某个范围
|
||||
case 'notbetween': // 验证是否不在某个范围
|
||||
if (is_array($rule)) {
|
||||
$min = $rule[0];
|
||||
@@ -429,7 +430,7 @@ trait Auto
|
||||
list($min, $max) = explode(',', $rule);
|
||||
}
|
||||
return 'between' == $type ? $value >= $min && $value <= $max : $value < $min || $value > $max;
|
||||
case 'equal':// 验证是否等于某个值
|
||||
case 'equal': // 验证是否等于某个值
|
||||
case 'notequal': // 验证是否等于某个值
|
||||
return 'equal' == $type ? $value == $rule : $value != $rule;
|
||||
case 'length': // 验证长度
|
||||
|
||||
Reference in New Issue
Block a user