diff --git a/src/Forms/Validator.php b/src/Forms/Validator.php index 5a311e1a3..5537c3fa0 100644 --- a/src/Forms/Validator.php +++ b/src/Forms/Validator.php @@ -159,6 +159,9 @@ public static function validateValid(Controls\BaseControl $control) */ public static function validateRange(IControl $control, $range) { + $range = array_map(function ($v) { + return $v === '' ? NULL : $v; + }, $range); return Validators::isInRange($control->getValue(), $range); } @@ -171,7 +174,7 @@ public static function validateRange(IControl $control, $range) */ public static function validateMin(IControl $control, $minimum) { - return Validators::isInRange($control->getValue(), [$minimum, NULL]); + return Validators::isInRange($control->getValue(), [$minimum === '' ? NULL : $minimum, NULL]); } @@ -183,7 +186,7 @@ public static function validateMin(IControl $control, $minimum) */ public static function validateMax(IControl $control, $maximum) { - return Validators::isInRange($control->getValue(), [NULL, $maximum]); + return Validators::isInRange($control->getValue(), [NULL, $maximum === '' ? NULL : $maximum]); }