diff --git a/src/Validators/Rules/IsLatitude.php b/src/Validators/Rules/IsLatitude.php index f3fc3db5..5085519e 100644 --- a/src/Validators/Rules/IsLatitude.php +++ b/src/Validators/Rules/IsLatitude.php @@ -18,6 +18,9 @@ final class IsLatitude extends IsFloat { + private float $min = -90.0; + private float $max = 90.0; + public function validateRule(?string $cellValue): ?string { if (!$this->getOptionAsBool()) { @@ -30,8 +33,8 @@ public function validateRule(?string $cellValue): ?string } $latitude = (float)$cellValue; - if ($latitude < -90.0 || $latitude > 90.0) { - return "Value \"{$cellValue}\" is not a valid latitude (-90 <= x <= 90)"; + if ($latitude < $this->min || $latitude > $this->max) { + return "Value \"{$cellValue}\" is not a valid latitude ({$this->min} <= x <= {$this->max})"; } return null; diff --git a/src/Validators/Rules/IsLongitude.php b/src/Validators/Rules/IsLongitude.php index f9198c47..97b06c28 100644 --- a/src/Validators/Rules/IsLongitude.php +++ b/src/Validators/Rules/IsLongitude.php @@ -18,6 +18,9 @@ final class IsLongitude extends IsFloat { + private float $min = -180.0; + private float $max = 180.0; + public function validateRule(?string $cellValue): ?string { if (!$this->getOptionAsBool()) { @@ -29,9 +32,9 @@ public function validateRule(?string $cellValue): ?string return $result; } - $latitude = (float)$cellValue; - if ($latitude < -180.0 || $latitude > 180.0) { - return "Value \"{$cellValue}\" is not a valid longitude (-180 <= x <= 180)"; + $longitude = (float)$cellValue; + if ($longitude < $this->min || $longitude > $this->max) { + return "Value \"{$cellValue}\" is not a valid longitude ({$this->min} <= x <= {$this->max})"; } return null;