@@ -308,6 +308,8 @@ bool isNotExpiredCreditCardDate(String str) {
308
308
return true ;
309
309
}
310
310
311
+ /// check if the string is a color
312
+ /// * [formats] is a list of color formats to check
311
313
bool isColorCode (String value,
312
314
{List <String > formats = const ['hex' , 'rgb' , 'hsl' ]}) {
313
315
if (formats.contains ('hex' ) && _hex.hasMatch (value)) {
@@ -359,10 +361,12 @@ bool isAlphabetical(String value) {
359
361
return _alphabetical.hasMatch (value);
360
362
}
361
363
364
+ /// check if the string is a valid UUID
362
365
bool isUUID (String value) {
363
366
return _uuid.hasMatch (value);
364
367
}
365
368
369
+ /// check if the string is valid JSON
366
370
bool isJSON (String value) {
367
371
try {
368
372
jsonDecode (value);
@@ -372,6 +376,7 @@ bool isJSON(String value) {
372
376
}
373
377
}
374
378
379
+ /// check if the string is a valid latitude
375
380
bool isLatitude (String value) {
376
381
value = value.replaceAll (',' , '.' );
377
382
@@ -382,6 +387,7 @@ bool isLatitude(String value) {
382
387
return latitude >= - 90 && latitude <= 90 ;
383
388
}
384
389
390
+ /// check if the string is a valid longitude
385
391
bool isLongitude (String value) {
386
392
value = value.replaceAll (',' , '.' );
387
393
@@ -392,6 +398,7 @@ bool isLongitude(String value) {
392
398
return longitude >= - 180 && longitude <= 180 ;
393
399
}
394
400
401
+ /// check if the string is a valid base64 string
395
402
bool isBase64 (String value) {
396
403
try {
397
404
base64Decode (value);
@@ -401,6 +408,7 @@ bool isBase64(String value) {
401
408
}
402
409
}
403
410
411
+ /// check if the string is a valid file path
404
412
bool isFilePath (String value) {
405
413
return _filePath.hasMatch (value);
406
414
}
@@ -415,6 +423,7 @@ bool isEvenNumber(String value) {
415
423
return number % 2 == 0 ;
416
424
}
417
425
426
+ /// check if the string is a valid MAC address
418
427
bool isMACAddress (String value) {
419
428
final splitChar = value.contains (':' ) ? ':' : '-' ;
420
429
final parts = value.split (splitChar);
@@ -430,6 +439,7 @@ bool isMACAddress(String value) {
430
439
return true ;
431
440
}
432
441
442
+ /// check if the string is a valid IBAN
433
443
bool isIBAN (String iban) {
434
444
iban = iban.replaceAll (' ' , '' ).toUpperCase ();
435
445
@@ -454,6 +464,7 @@ bool isIBAN(String iban) {
454
464
return remainder == 1 ;
455
465
}
456
466
467
+ /// check if the string is a valid BIC
457
468
bool isBIC (String bic) {
458
469
bic = bic.replaceAll (' ' , '' ).toUpperCase ();
459
470
@@ -464,9 +475,10 @@ bool isBIC(String bic) {
464
475
return _bic.hasMatch (bic);
465
476
}
466
477
478
+ /// check if the string is a valid ISBN
467
479
bool isISBN (String isbn) {
468
- isbn = isbn.replaceAll ('-' , '' ).replaceAll (' ' , '' ); // Remove hyphens and spaces
469
-
480
+ isbn = isbn.replaceAll ('-' , '' ).replaceAll (' ' , '' );
481
+
470
482
if (isbn.length == 10 ) {
471
483
if (! RegExp (r'^\d{9}[\dX]$' ).hasMatch (isbn)) return false ;
472
484
0 commit comments