@@ -471,10 +471,12 @@ 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+ return rescue (function () use ($ attribute , $ value , $ parameters ) {
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+ }, false , false );
478480 }
479481
480482 /**
@@ -1223,22 +1225,29 @@ public function validateGt($attribute, $value, $parameters)
12231225 $ this ->shouldBeNumeric ($ attribute , 'Gt ' );
12241226
12251227 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1226- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThan ($ this ->trim ($ parameters [0 ]));
1228+ return rescue (
1229+ fn () => BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThan ($ this ->trim ($ parameters [0 ])), false , false
1230+ );
12271231 }
12281232
12291233 if (is_numeric ($ parameters [0 ])) {
12301234 return false ;
12311235 }
12321236
12331237 if ($ this ->hasRule ($ attribute , $ this ->numericRules ) && is_numeric ($ value ) && is_numeric ($ comparedToValue )) {
1234- return BigNumber::of ($ this ->trim ($ value ))->isGreaterThan ($ this ->trim ($ comparedToValue ));
1238+ return rescue (
1239+ fn () => BigNumber::of ($ this ->trim ($ value ))->isGreaterThan ($ this ->trim ($ comparedToValue )),
1240+ false
1241+ );
12351242 }
12361243
12371244 if (! $ this ->isSameType ($ value , $ comparedToValue )) {
12381245 return false ;
12391246 }
12401247
1241- return $ this ->getSize ($ attribute , $ value ) > $ this ->getSize ($ attribute , $ comparedToValue );
1248+ return rescue (
1249+ fn () => $ this ->getSize ($ attribute , $ value ) > $ this ->getSize ($ attribute , $ comparedToValue ), false , false
1250+ );
12421251 }
12431252
12441253 /**
@@ -1258,7 +1267,9 @@ public function validateLt($attribute, $value, $parameters)
12581267 $ this ->shouldBeNumeric ($ attribute , 'Lt ' );
12591268
12601269 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1261- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThan ($ this ->trim ($ parameters [0 ]));
1270+ return rescue (
1271+ fn () => BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThan ($ this ->trim ($ parameters [0 ])), false , false
1272+ );
12621273 }
12631274
12641275 if (is_numeric ($ parameters [0 ])) {
@@ -1273,7 +1284,9 @@ public function validateLt($attribute, $value, $parameters)
12731284 return false ;
12741285 }
12751286
1276- return $ this ->getSize ($ attribute , $ value ) < $ this ->getSize ($ attribute , $ comparedToValue );
1287+ return rescue (
1288+ fn () => $ this ->getSize ($ attribute , $ value ) < $ this ->getSize ($ attribute , $ comparedToValue ), false , false
1289+ );
12771290 }
12781291
12791292 /**
@@ -1293,22 +1306,29 @@ public function validateGte($attribute, $value, $parameters)
12931306 $ this ->shouldBeNumeric ($ attribute , 'Gte ' );
12941307
12951308 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1296- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1309+ return rescue (
1310+ fn () => BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ])), false , false
1311+ );
12971312 }
12981313
12991314 if (is_numeric ($ parameters [0 ])) {
13001315 return false ;
13011316 }
13021317
13031318 if ($ this ->hasRule ($ attribute , $ this ->numericRules ) && is_numeric ($ value ) && is_numeric ($ comparedToValue )) {
1304- return BigNumber::of ($ this ->trim ($ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ comparedToValue ));
1319+ return rescue (
1320+ fn () => BigNumber::of ($ this ->trim ($ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ comparedToValue )),
1321+ false
1322+ );
13051323 }
13061324
13071325 if (! $ this ->isSameType ($ value , $ comparedToValue )) {
13081326 return false ;
13091327 }
13101328
1311- return $ this ->getSize ($ attribute , $ value ) >= $ this ->getSize ($ attribute , $ comparedToValue );
1329+ return rescue (
1330+ fn () => $ this ->getSize ($ attribute , $ value ) >= $ this ->getSize ($ attribute , $ comparedToValue ), false , false
1331+ );
13121332 }
13131333
13141334 /**
@@ -1328,7 +1348,9 @@ public function validateLte($attribute, $value, $parameters)
13281348 $ this ->shouldBeNumeric ($ attribute , 'Lte ' );
13291349
13301350 if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1331- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1351+ return rescue (
1352+ fn () => BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ])), false , false
1353+ );
13321354 }
13331355
13341356 if (is_numeric ($ parameters [0 ])) {
@@ -1343,7 +1365,9 @@ public function validateLte($attribute, $value, $parameters)
13431365 return false ;
13441366 }
13451367
1346- return $ this ->getSize ($ attribute , $ value ) <= $ this ->getSize ($ attribute , $ comparedToValue );
1368+ return rescue (
1369+ fn () => $ this ->getSize ($ attribute , $ value ) <= $ this ->getSize ($ attribute , $ comparedToValue ), false , false
1370+ );
13471371 }
13481372
13491373 /**
@@ -1544,7 +1568,9 @@ public function validateMax($attribute, $value, $parameters)
15441568 return false ;
15451569 }
15461570
1547- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1571+ return rescue (
1572+ fn () => BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ])), false , false
1573+ );
15481574 }
15491575
15501576 /**
@@ -1646,7 +1672,9 @@ public function validateMin($attribute, $value, $parameters)
16461672 {
16471673 $ this ->requireParameterCount (1 , $ parameters , 'min ' );
16481674
1649- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1675+ return rescue (
1676+ fn () => BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ])), false , false
1677+ );
16501678 }
16511679
16521680 /**
@@ -2466,7 +2494,9 @@ public function validateSize($attribute, $value, $parameters)
24662494 {
24672495 $ this ->requireParameterCount (1 , $ parameters , 'size ' );
24682496
2469- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isEqualTo ($ this ->trim ($ parameters [0 ]));
2497+ return rescue (
2498+ fn () => BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isEqualTo ($ this ->trim ($ parameters [0 ])), false , false
2499+ );
24702500 }
24712501
24722502 /**
@@ -2738,6 +2768,8 @@ protected function trim($value)
27382768 * @param string $attribute
27392769 * @param mixed $value
27402770 * @return mixed
2771+ *
2772+ * @throws \Illuminate\Support\Exceptions\MathException
27412773 */
27422774 protected function ensureExponentWithinAllowedRange ($ attribute , $ value )
27432775 {
0 commit comments