@@ -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
/**
@@ -1224,22 +1228,34 @@ public function validateGt($attribute, $value, $parameters)
1224
1228
$ this ->shouldBeNumeric ($ attribute , 'Gt ' );
1225
1229
1226
1230
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
+ }
1228
1236
}
1229
1237
1230
1238
if (is_numeric ($ parameters [0 ])) {
1231
1239
return false ;
1232
1240
}
1233
1241
1234
1242
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
+ }
1236
1248
}
1237
1249
1238
1250
if (! $ this ->isSameType ($ value , $ comparedToValue )) {
1239
1251
return false ;
1240
1252
}
1241
1253
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
+ }
1243
1259
}
1244
1260
1245
1261
/**
@@ -1259,7 +1275,11 @@ public function validateLt($attribute, $value, $parameters)
1259
1275
$ this ->shouldBeNumeric ($ attribute , 'Lt ' );
1260
1276
1261
1277
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
+ }
1263
1283
}
1264
1284
1265
1285
if (is_numeric ($ parameters [0 ])) {
@@ -1274,7 +1294,11 @@ public function validateLt($attribute, $value, $parameters)
1274
1294
return false ;
1275
1295
}
1276
1296
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
+ }
1278
1302
}
1279
1303
1280
1304
/**
@@ -1294,22 +1318,34 @@ public function validateGte($attribute, $value, $parameters)
1294
1318
$ this ->shouldBeNumeric ($ attribute , 'Gte ' );
1295
1319
1296
1320
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
+ }
1298
1326
}
1299
1327
1300
1328
if (is_numeric ($ parameters [0 ])) {
1301
1329
return false ;
1302
1330
}
1303
1331
1304
1332
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
+ }
1306
1338
}
1307
1339
1308
1340
if (! $ this ->isSameType ($ value , $ comparedToValue )) {
1309
1341
return false ;
1310
1342
}
1311
1343
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
+ }
1313
1349
}
1314
1350
1315
1351
/**
@@ -1329,7 +1365,11 @@ public function validateLte($attribute, $value, $parameters)
1329
1365
$ this ->shouldBeNumeric ($ attribute , 'Lte ' );
1330
1366
1331
1367
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
+ }
1333
1373
}
1334
1374
1335
1375
if (is_numeric ($ parameters [0 ])) {
@@ -1344,7 +1384,11 @@ public function validateLte($attribute, $value, $parameters)
1344
1384
return false ;
1345
1385
}
1346
1386
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
+ }
1348
1392
}
1349
1393
1350
1394
/**
@@ -1579,7 +1623,11 @@ public function validateMax($attribute, $value, $parameters)
1579
1623
return false ;
1580
1624
}
1581
1625
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
+ }
1583
1631
}
1584
1632
1585
1633
/**
@@ -1681,7 +1729,11 @@ public function validateMin($attribute, $value, $parameters)
1681
1729
{
1682
1730
$ this ->requireParameterCount (1 , $ parameters , 'min ' );
1683
1731
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
+ }
1685
1737
}
1686
1738
1687
1739
/**
@@ -2501,7 +2553,11 @@ public function validateSize($attribute, $value, $parameters)
2501
2553
{
2502
2554
$ this ->requireParameterCount (1 , $ parameters , 'size ' );
2503
2555
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
+ }
2505
2561
}
2506
2562
2507
2563
/**
@@ -2784,6 +2840,8 @@ protected function trim($value)
2784
2840
* @param string $attribute
2785
2841
* @param mixed $value
2786
2842
* @return mixed
2843
+ *
2844
+ * @throws \Illuminate\Support\Exceptions\MathException
2787
2845
*/
2788
2846
protected function ensureExponentWithinAllowedRange ($ attribute , $ value )
2789
2847
{
0 commit comments