@@ -471,10 +471,14 @@ public function validateBetween($attribute, $value, $parameters)
471
471
{
472
472
$ this ->requireParameterCount (2 , $ parameters , 'between ' );
473
473
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
+ }
478
482
}
479
483
480
484
/**
@@ -1223,22 +1227,34 @@ public function validateGt($attribute, $value, $parameters)
1223
1227
$ this ->shouldBeNumeric ($ attribute , 'Gt ' );
1224
1228
1225
1229
if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1226
- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThan ($ this ->trim ($ parameters [0 ]));
1230
+ try {
1231
+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThan ($ this ->trim ($ parameters [0 ]));
1232
+ } catch (MathException ) {
1233
+ return false ;
1234
+ }
1227
1235
}
1228
1236
1229
1237
if (is_numeric ($ parameters [0 ])) {
1230
1238
return false ;
1231
1239
}
1232
1240
1233
1241
if ($ this ->hasRule ($ attribute , $ this ->numericRules ) && is_numeric ($ value ) && is_numeric ($ comparedToValue )) {
1234
- return BigNumber::of ($ this ->trim ($ value ))->isGreaterThan ($ this ->trim ($ comparedToValue ));
1242
+ try {
1243
+ return BigNumber::of ($ this ->trim ($ value ))->isGreaterThan ($ this ->trim ($ comparedToValue ));
1244
+ } catch (MathException ) {
1245
+ return false ;
1246
+ }
1235
1247
}
1236
1248
1237
1249
if (! $ this ->isSameType ($ value , $ comparedToValue )) {
1238
1250
return false ;
1239
1251
}
1240
1252
1241
- return $ this ->getSize ($ attribute , $ value ) > $ this ->getSize ($ attribute , $ comparedToValue );
1253
+ try {
1254
+ return $ this ->getSize ($ attribute , $ value ) > $ this ->getSize ($ attribute , $ comparedToValue );
1255
+ } catch (MathException ) {
1256
+ return false ;
1257
+ }
1242
1258
}
1243
1259
1244
1260
/**
@@ -1258,7 +1274,11 @@ public function validateLt($attribute, $value, $parameters)
1258
1274
$ this ->shouldBeNumeric ($ attribute , 'Lt ' );
1259
1275
1260
1276
if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1261
- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThan ($ this ->trim ($ parameters [0 ]));
1277
+ try {
1278
+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThan ($ this ->trim ($ parameters [0 ]));
1279
+ } catch (MathException ) {
1280
+ return false ;
1281
+ }
1262
1282
}
1263
1283
1264
1284
if (is_numeric ($ parameters [0 ])) {
@@ -1273,7 +1293,11 @@ public function validateLt($attribute, $value, $parameters)
1273
1293
return false ;
1274
1294
}
1275
1295
1276
- return $ this ->getSize ($ attribute , $ value ) < $ this ->getSize ($ attribute , $ comparedToValue );
1296
+ try {
1297
+ return $ this ->getSize ($ attribute , $ value ) < $ this ->getSize ($ attribute , $ comparedToValue );
1298
+ } catch (MathException ) {
1299
+ return false ;
1300
+ }
1277
1301
}
1278
1302
1279
1303
/**
@@ -1293,22 +1317,34 @@ public function validateGte($attribute, $value, $parameters)
1293
1317
$ this ->shouldBeNumeric ($ attribute , 'Gte ' );
1294
1318
1295
1319
if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1296
- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1320
+ try {
1321
+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1322
+ } catch (MathException ) {
1323
+ return false ;
1324
+ }
1297
1325
}
1298
1326
1299
1327
if (is_numeric ($ parameters [0 ])) {
1300
1328
return false ;
1301
1329
}
1302
1330
1303
1331
if ($ this ->hasRule ($ attribute , $ this ->numericRules ) && is_numeric ($ value ) && is_numeric ($ comparedToValue )) {
1304
- return BigNumber::of ($ this ->trim ($ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ comparedToValue ));
1332
+ try {
1333
+ return BigNumber::of ($ this ->trim ($ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ comparedToValue ));
1334
+ } catch (MathException ) {
1335
+ return false ;
1336
+ }
1305
1337
}
1306
1338
1307
1339
if (! $ this ->isSameType ($ value , $ comparedToValue )) {
1308
1340
return false ;
1309
1341
}
1310
1342
1311
- return $ this ->getSize ($ attribute , $ value ) >= $ this ->getSize ($ attribute , $ comparedToValue );
1343
+ try {
1344
+ return $ this ->getSize ($ attribute , $ value ) >= $ this ->getSize ($ attribute , $ comparedToValue );
1345
+ } catch (MathException ) {
1346
+ return false ;
1347
+ }
1312
1348
}
1313
1349
1314
1350
/**
@@ -1328,7 +1364,11 @@ public function validateLte($attribute, $value, $parameters)
1328
1364
$ this ->shouldBeNumeric ($ attribute , 'Lte ' );
1329
1365
1330
1366
if (is_null ($ comparedToValue ) && (is_numeric ($ value ) && is_numeric ($ parameters [0 ]))) {
1331
- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1367
+ try {
1368
+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1369
+ } catch (MathException ) {
1370
+ return false ;
1371
+ }
1332
1372
}
1333
1373
1334
1374
if (is_numeric ($ parameters [0 ])) {
@@ -1343,7 +1383,11 @@ public function validateLte($attribute, $value, $parameters)
1343
1383
return false ;
1344
1384
}
1345
1385
1346
- return $ this ->getSize ($ attribute , $ value ) <= $ this ->getSize ($ attribute , $ comparedToValue );
1386
+ try {
1387
+ return $ this ->getSize ($ attribute , $ value ) <= $ this ->getSize ($ attribute , $ comparedToValue );
1388
+ } catch (MathException ) {
1389
+ return false ;
1390
+ }
1347
1391
}
1348
1392
1349
1393
/**
@@ -1544,7 +1588,11 @@ public function validateMax($attribute, $value, $parameters)
1544
1588
return false ;
1545
1589
}
1546
1590
1547
- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1591
+ try {
1592
+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isLessThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1593
+ } catch (MathException ) {
1594
+ return false ;
1595
+ }
1548
1596
}
1549
1597
1550
1598
/**
@@ -1646,7 +1694,11 @@ public function validateMin($attribute, $value, $parameters)
1646
1694
{
1647
1695
$ this ->requireParameterCount (1 , $ parameters , 'min ' );
1648
1696
1649
- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1697
+ try {
1698
+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isGreaterThanOrEqualTo ($ this ->trim ($ parameters [0 ]));
1699
+ } catch (MathException ) {
1700
+ return false ;
1701
+ }
1650
1702
}
1651
1703
1652
1704
/**
@@ -2466,7 +2518,11 @@ public function validateSize($attribute, $value, $parameters)
2466
2518
{
2467
2519
$ this ->requireParameterCount (1 , $ parameters , 'size ' );
2468
2520
2469
- return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isEqualTo ($ this ->trim ($ parameters [0 ]));
2521
+ try {
2522
+ return BigNumber::of ($ this ->getSize ($ attribute , $ value ))->isEqualTo ($ this ->trim ($ parameters [0 ]));
2523
+ } catch (MathException ) {
2524
+ return false ;
2525
+ }
2470
2526
}
2471
2527
2472
2528
/**
@@ -2738,6 +2794,8 @@ protected function trim($value)
2738
2794
* @param string $attribute
2739
2795
* @param mixed $value
2740
2796
* @return mixed
2797
+ *
2798
+ * @throws \Illuminate\Support\Exceptions\MathException
2741
2799
*/
2742
2800
protected function ensureExponentWithinAllowedRange ($ attribute , $ value )
2743
2801
{
0 commit comments