Skip to content

Commit

Permalink
支持2.0版本,增加int 数组int验证
Browse files Browse the repository at this point in the history
  • Loading branch information
lphkxd committed Jul 12, 2020
1 parent 27310b0 commit 458f623
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Validate/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class Validate
'fileExt' => '上传文件后缀不符',
'fileMime' => '上传文件类型不符',
'unique' => ':attribute 已存在',
'arrayHasOnlyInts' => ':attribute 只允许为int类型或array(int,int)',
'arrayHasOnlyInts' => ':attribute 只允许为array(int,int)',
'intOrArrayInt' => ':attribute 只允许为int类型或array(int,int)',
'afterWith' => ':attribute cannot be less than :rule',
'beforeWith' => ':attribute cannot exceed :rule',

Expand Down Expand Up @@ -1653,6 +1654,18 @@ public function getSceneRule(string $name)
return $this->scene[$name] ?? $this->rule;
}

function intOrArrayInt($array)
{
if (is_int($array)) return true;
foreach ($array as $value) {
if (!is_int($value)) // there are several ways to do this
{
return false;
}
}
return true;
}

function arrayHasOnlyInts($array)
{
foreach ($array as $value) {
Expand Down

0 comments on commit 458f623

Please sign in to comment.