This commit is contained in:
as2252258@163.com
2021-04-07 01:53:32 +08:00
parent c3617e89d5
commit ed6cb4cf28
4 changed files with 580 additions and 627 deletions
+3 -3
View File
@@ -60,7 +60,7 @@ class LengthValidator extends BaseValidator
return $this->addError('The param :attribute length overflow');
}
} else {
if (is_numeric($value) && strlen(floatval($value)) > $this->value) {
if (is_numeric($value) && strlen((string)$value) > $this->value) {
return $this->addError('The param :attribute length overflow');
}
if (strlen($value) > $this->value) {
@@ -83,7 +83,7 @@ class LengthValidator extends BaseValidator
return $this->addError('The param :attribute length error');
}
} else {
if (is_numeric($value) && strlen(floatval($value)) < $this->value) {
if (is_numeric($value) && strlen((string)$value) < $this->value) {
return $this->addError('The param :attribute length overflow');
}
if (strlen($value) < $this->value) {
@@ -106,7 +106,7 @@ class LengthValidator extends BaseValidator
return $this->addError('The param :attribute length error');
}
} else {
if (is_numeric($value) && mb_strlen(floatval($value)) !== $this->value) {
if (is_numeric($value) && strlen((string)$value) !== $this->value) {
return $this->addError('The param :attribute length overflow');
}
if (mb_strlen($value) !== $this->value) {
+2 -2
View File
@@ -126,7 +126,7 @@ class TypesOfValidator extends BaseValidator
if (!is_numeric($value)) {
return $this->addError('The ' . $this->field . ' not is number data.');
}
if (intval($value) != $value) {
if ((int)$value != $value) {
return $this->addError('The ' . $this->field . ' not is number data.');
}
@@ -139,7 +139,7 @@ class TypesOfValidator extends BaseValidator
*/
public function floatFormat($value): bool
{
$trim = floatval((string)$value);
$trim = (float)$value;
if ($trim != $value || !is_float($trim)) {
return $this->addError('The ' . $this->field . ' not is float data.');
}