@@ -471,10 +471,14 @@ public function validateBetween($attribute, $value, $parameters)
471471 {
472472 $ this ->requireParameterCount (2 , $ parameters , 'between ' );
473473
474- return with (
475- BigNumber::of ($ this ->getSize ($ attribute , $ value )),
476- fn ($ size ) => $ size ->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ])) && $ size ->isLessThanOrEqualTo ($ this ->trim ($ parameters [1 ]))
477- );
474+ try {
475+ return with (
476+ BigNumber::of ($ this ->getSize ($ attribute , $ value )),
477+ fn ($ size ) => $ size ->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ])) && $ size ->isLessThanOrEqualTo ($ this ->trim ($ parameters [1 ]))
478+ );
479+ } catch (MathException ) {
480+ return false ;
481+ }
478482 }
479483
480484 /**
@@ -1224,22 +1228,34 @@ public function validateGt($attribute, $value, $parameters)
12241228 $ this ->shouldBeNumeric ($ attribute , 'Gt ' );
12251229
12261230 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1227- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThan ($ this ->trim ($ parameters [0 ]));
1231+ try {
1232+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThan ($ this ->trim ($ parameters [0 ]));
1233+ } catch (MathException ) {
1234+ return false ;
1235+ }
12281236 }
12291237
12301238 if (is_numeric ($ parameters [0 ])) {
12311239 return false ;
12321240 }
12331241
12341242 if ($ this ->hasRule ($ attribute , $ this ->numericRules ) && is_numeric ($ value ) && is_numeric ($ comparedToValue )) {
1235- return BigNumber::of ($ this ->trim ($ value ))->isGreaterThan ($ this ->trim ($ comparedToValue ));
1243+ try {
1244+ return BigNumber::of ($ this ->trim ($ value ))->isGreaterThan ($ this ->trim ($ comparedToValue ));
1245+ } catch (MathException ) {
1246+ return false ;
1247+ }
12361248 }
12371249
12381250 if (! $ this ->isSameType ($ value , $ comparedToValue )) {
12391251 return false ;
12401252 }
12411253
1242- return $ this ->getSize ($ attribute , $ value ) > $ this ->getSize ($ attribute , $ comparedToValue );
1254+ try {
1255+ return $ this ->getSize ($ attribute , $ value ) > $ this ->getSize ($ attribute , $ comparedToValue );
1256+ } catch (MathException ) {
1257+ return false ;
1258+ }
12431259 }
12441260
12451261 /**
@@ -1259,7 +1275,11 @@ public function validateLt($attribute, $value, $parameters)
12591275 $ this ->shouldBeNumeric ($ attribute , 'Lt ' );
12601276
12611277 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1262- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThan ($ this ->trim ($ parameters [0 ]));
1278+ try {
1279+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThan ($ this ->trim ($ parameters [0 ]));
1280+ } catch (MathException ) {
1281+ return false ;
1282+ }
12631283 }
12641284
12651285 if (is_numeric ($ parameters [0 ])) {
@@ -1274,7 +1294,11 @@ public function validateLt($attribute, $value, $parameters)
12741294 return false ;
12751295 }
12761296
1277- return $ this ->getSize ($ attribute , $ value ) < $ this ->getSize ($ attribute , $ comparedToValue );
1297+ try {
1298+ return $ this ->getSize ($ attribute , $ value ) < $ this ->getSize ($ attribute , $ comparedToValue );
1299+ } catch (MathException ) {
1300+ return false ;
1301+ }
12781302 }
12791303
12801304 /**
@@ -1294,22 +1318,34 @@ public function validateGte($attribute, $value, $parameters)
12941318 $ this ->shouldBeNumeric ($ attribute , 'Gte ' );
12951319
12961320 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1297- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1321+ try {
1322+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1323+ } catch (MathException ) {
1324+ return false ;
1325+ }
12981326 }
12991327
13001328 if (is_numeric ($ parameters [0 ])) {
13011329 return false ;
13021330 }
13031331
13041332 if ($ this ->hasRule ($ attribute , $ this ->numericRules ) && is_numeric ($ value ) && is_numeric ($ comparedToValue )) {
1305- return BigNumber::of ($ this ->trim ($ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ comparedToValue ));
1333+ try {
1334+ return BigNumber::of ($ this ->trim ($ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ comparedToValue ));
1335+ } catch (MathException ) {
1336+ return false ;
1337+ }
13061338 }
13071339
13081340 if (! $ this ->isSameType ($ value , $ comparedToValue )) {
13091341 return false ;
13101342 }
13111343
1312- return $ this ->getSize ($ attribute , $ value ) >= $ this ->getSize ($ attribute , $ comparedToValue );
1344+ try {
1345+ return $ this ->getSize ($ attribute , $ value ) >= $ this ->getSize ($ attribute , $ comparedToValue );
1346+ } catch (MathException ) {
1347+ return false ;
1348+ }
13131349 }
13141350
13151351 /**
@@ -1329,7 +1365,11 @@ public function validateLte($attribute, $value, $parameters)
13291365 $ this ->shouldBeNumeric ($ attribute , 'Lte ' );
13301366
13311367 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1332- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1368+ try {
1369+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1370+ } catch (MathException ) {
1371+ return false ;
1372+ }
13331373 }
13341374
13351375 if (is_numeric ($ parameters [0 ])) {
@@ -1344,7 +1384,11 @@ public function validateLte($attribute, $value, $parameters)
13441384 return false ;
13451385 }
13461386
1347- return $ this ->getSize ($ attribute , $ value ) <= $ this ->getSize ($ attribute , $ comparedToValue );
1387+ try {
1388+ return $ this ->getSize ($ attribute , $ value ) <= $ this ->getSize ($ attribute , $ comparedToValue );
1389+ } catch (MathException ) {
1390+ return false ;
1391+ }
13481392 }
13491393
13501394 /**
@@ -1579,7 +1623,11 @@ public function validateMax($attribute, $value, $parameters)
15791623 return false ;
15801624 }
15811625
1582- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1626+ try {
1627+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1628+ } catch (MathException ) {
1629+ return false ;
1630+ }
15831631 }
15841632
15851633 /**
@@ -1681,7 +1729,11 @@ public function validateMin($attribute, $value, $parameters)
16811729 {
16821730 $ this ->requireParameterCount (1 , $ parameters , 'min ' );
16831731
1684- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1732+ try {
1733+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1734+ } catch (MathException ) {
1735+ return false ;
1736+ }
16851737 }
16861738
16871739 /**
@@ -2501,7 +2553,11 @@ public function validateSize($attribute, $value, $parameters)
25012553 {
25022554 $ this ->requireParameterCount (1 , $ parameters , 'size ' );
25032555
2504- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isEqualTo ($ this ->trim ($ parameters [0 ]));
2556+ try {
2557+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isEqualTo ($ this ->trim ($ parameters [0 ]));
2558+ } catch (MathException ) {
2559+ return false ;
2560+ }
25052561 }
25062562
25072563 /**
@@ -2784,6 +2840,8 @@ protected function trim($value)
27842840 * @param string $attribute
27852841 * @param mixed $value
27862842 * @return mixed
2843+ *
2844+ * @throws \Illuminate\Support\Exceptions\MathException
27872845 */
27882846 protected function ensureExponentWithinAllowedRange ($ attribute , $ value )
27892847 {
0 commit comments