mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
改进requireIf requireWith requireCallback验证规则及内置错误提示
This commit is contained in:
@@ -900,7 +900,7 @@ class Validate
|
|||||||
{
|
{
|
||||||
list($field, $val) = explode(',', $rule);
|
list($field, $val) = explode(',', $rule);
|
||||||
if ($this->getDataValue($data, $field) == $val) {
|
if ($this->getDataValue($data, $field) == $val) {
|
||||||
return !empty($value);
|
return !empty($value) || '0' == $value;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -918,7 +918,7 @@ class Validate
|
|||||||
{
|
{
|
||||||
$result = call_user_func_array($rule, [$value, $data]);
|
$result = call_user_func_array($rule, [$value, $data]);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return !empty($value);
|
return !empty($value) || '0' == $value;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -936,7 +936,7 @@ class Validate
|
|||||||
{
|
{
|
||||||
$val = $this->getDataValue($data, $rule);
|
$val = $this->getDataValue($data, $rule);
|
||||||
if (!empty($val)) {
|
if (!empty($val)) {
|
||||||
return !empty($value);
|
return !empty($value) || '0' == $value;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1226,6 +1226,8 @@ class Validate
|
|||||||
$msg = $this->message[$attribute];
|
$msg = $this->message[$attribute];
|
||||||
} elseif (isset(self::$typeMsg[$type])) {
|
} elseif (isset(self::$typeMsg[$type])) {
|
||||||
$msg = self::$typeMsg[$type];
|
$msg = self::$typeMsg[$type];
|
||||||
|
} elseif (0 === strpos($type, 'require')) {
|
||||||
|
$msg = self::$typeMsg['require'];
|
||||||
} else {
|
} else {
|
||||||
$msg = $title . '规则错误';
|
$msg = $title . '规则错误';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user