@@ -348,7 +348,7 @@ class FormBuilderValidators {
348
348
List <String > hostWhitelist = const [],
349
349
List <String > hostBlacklist = const [],
350
350
}) =>
351
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
351
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
352
352
! isURL (
353
353
valueCandidate,
354
354
protocols: protocols,
@@ -368,7 +368,7 @@ class FormBuilderValidators {
368
368
String pattern, {
369
369
String ? errorText,
370
370
}) =>
371
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
371
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
372
372
! RegExp (pattern).hasMatch (valueCandidate! )
373
373
? errorText ?? FormBuilderLocalizations .current.matchErrorText
374
374
: null ;
@@ -380,7 +380,7 @@ class FormBuilderValidators {
380
380
String pattern, {
381
381
String ? errorText,
382
382
}) =>
383
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
383
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
384
384
RegExp (pattern).hasMatch (valueCandidate! )
385
385
? errorText ?? FormBuilderLocalizations .current.matchErrorText
386
386
: null ;
@@ -390,7 +390,7 @@ class FormBuilderValidators {
390
390
static FormFieldValidator <String > numeric ({
391
391
String ? errorText,
392
392
}) =>
393
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
393
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
394
394
null == num .tryParse (valueCandidate! )
395
395
? errorText ?? FormBuilderLocalizations .current.numericErrorText
396
396
: null ;
@@ -402,7 +402,7 @@ class FormBuilderValidators {
402
402
String ? errorText,
403
403
int ? radix,
404
404
}) =>
405
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
405
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
406
406
null == int .tryParse (valueCandidate! , radix: radix)
407
407
? errorText ?? FormBuilderLocalizations .current.integerErrorText
408
408
: null ;
@@ -412,7 +412,7 @@ class FormBuilderValidators {
412
412
static FormFieldValidator <String > creditCard ({
413
413
String ? errorText,
414
414
}) =>
415
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
415
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
416
416
! isCreditCard (valueCandidate! )
417
417
? errorText ?? FormBuilderLocalizations .current.creditCardErrorText
418
418
: null ;
@@ -424,7 +424,7 @@ class FormBuilderValidators {
424
424
bool checkForExpiration = true ,
425
425
String ? errorText,
426
426
}) =>
427
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
427
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
428
428
! isCreditCardExpirationDate (valueCandidate! )
429
429
? errorText ??
430
430
FormBuilderLocalizations .current.creditCardExpirationDateErrorText
@@ -457,7 +457,7 @@ class FormBuilderValidators {
457
457
String ? errorText,
458
458
}) =>
459
459
(valueCandidate) =>
460
- true == valueCandidate? .isNotEmpty && ! isIP (valueCandidate, version)
460
+ valueCandidate? .isNotEmpty == true && ! isIP (valueCandidate, version)
461
461
? errorText ?? FormBuilderLocalizations .current.ipErrorText
462
462
: null ;
463
463
@@ -466,7 +466,7 @@ class FormBuilderValidators {
466
466
static FormFieldValidator <String > dateString ({
467
467
String ? errorText,
468
468
}) =>
469
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
469
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
470
470
! isDate (valueCandidate! )
471
471
? errorText ?? FormBuilderLocalizations .current.dateStringErrorText
472
472
: null ;
@@ -515,7 +515,7 @@ class FormBuilderValidators {
515
515
List <String > formats = const ['hex' , 'rgb' , 'hsl' ],
516
516
String ? errorText,
517
517
}) =>
518
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
518
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
519
519
! isColorCode (valueCandidate! , formats: formats)
520
520
? errorText ??
521
521
FormBuilderLocalizations .current
@@ -527,7 +527,7 @@ class FormBuilderValidators {
527
527
static FormFieldValidator <String > uppercase ({
528
528
String ? errorText,
529
529
}) =>
530
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
530
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
531
531
valueCandidate! .toUpperCase () != valueCandidate
532
532
? errorText ?? FormBuilderLocalizations .current.uppercaseErrorText
533
533
: null ;
@@ -537,7 +537,7 @@ class FormBuilderValidators {
537
537
static FormFieldValidator <String > lowercase ({
538
538
String ? errorText,
539
539
}) =>
540
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
540
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
541
541
valueCandidate! .toLowerCase () != valueCandidate
542
542
? errorText ?? FormBuilderLocalizations .current.lowercaseErrorText
543
543
: null ;
@@ -661,7 +661,7 @@ class FormBuilderValidators {
661
661
int atLeast = 1 ,
662
662
String ? errorText,
663
663
}) =>
664
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
664
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
665
665
specialCharLength (valueCandidate! ) >= atLeast
666
666
? null
667
667
: errorText ??
@@ -675,7 +675,7 @@ class FormBuilderValidators {
675
675
int atLeast = 1 ,
676
676
String ? errorText,
677
677
}) =>
678
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
678
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
679
679
uppercaseCharLength (valueCandidate! ) >= atLeast
680
680
? null
681
681
: errorText ??
@@ -689,7 +689,7 @@ class FormBuilderValidators {
689
689
int atLeast = 1 ,
690
690
String ? errorText,
691
691
}) =>
692
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
692
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
693
693
lowercaseCharLength (valueCandidate! ) >= atLeast
694
694
? null
695
695
: errorText ??
@@ -703,7 +703,7 @@ class FormBuilderValidators {
703
703
int atLeast = 1 ,
704
704
String ? errorText,
705
705
}) =>
706
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
706
+ (valueCandidate) => valueCandidate? .isNotEmpty == true &&
707
707
numberCharLength (valueCandidate! ) >= atLeast
708
708
? null
709
709
: errorText ??
@@ -751,8 +751,9 @@ class FormBuilderValidators {
751
751
static FormFieldValidator <String > alphabetical ({
752
752
String ? errorText,
753
753
}) =>
754
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
755
- ! isAlphabetical (valueCandidate! )
754
+ (valueCandidate) => valueCandidate == null ||
755
+ valueCandidate.isEmpty ||
756
+ ! isAlphabetical (valueCandidate)
756
757
? errorText ?? FormBuilderLocalizations .current.alphabeticalErrorText
757
758
: null ;
758
759
@@ -761,18 +762,19 @@ class FormBuilderValidators {
761
762
static FormFieldValidator <String > uuid ({
762
763
String ? errorText,
763
764
}) =>
764
- (valueCandidate) =>
765
- true == valueCandidate? .isNotEmpty && ! isUUID (valueCandidate! )
766
- ? errorText ?? FormBuilderLocalizations .current.uuidErrorText
767
- : null ;
765
+ (valueCandidate) => valueCandidate == null ||
766
+ valueCandidate.isEmpty ||
767
+ ! isUUID (valueCandidate)
768
+ ? errorText ?? FormBuilderLocalizations .current.uuidErrorText
769
+ : null ;
768
770
769
771
/// [FormFieldValidator] that requires the field's value to be valid json.
770
772
/// * [errorText] is the error message to display when the json is invalid
771
773
static FormFieldValidator <String > json ({
772
774
String ? errorText,
773
775
}) =>
774
776
(valueCandidate) =>
775
- true == valueCandidate? .isNotEmpty && ! isJSON (valueCandidate! )
777
+ valueCandidate? .isEmpty != false || ! isJSON (valueCandidate! )
776
778
? errorText ?? FormBuilderLocalizations .current.jsonErrorText
777
779
: null ;
778
780
@@ -782,7 +784,7 @@ class FormBuilderValidators {
782
784
String ? errorText,
783
785
}) =>
784
786
(valueCandidate) =>
785
- true == valueCandidate? .isNotEmpty && ! isLatitude (valueCandidate! )
787
+ valueCandidate? .isEmpty != false || ! isLatitude (valueCandidate! )
786
788
? errorText ?? FormBuilderLocalizations .current.latitudeErrorText
787
789
: null ;
788
790
@@ -792,7 +794,7 @@ class FormBuilderValidators {
792
794
String ? errorText,
793
795
}) =>
794
796
(valueCandidate) =>
795
- true == valueCandidate? .isNotEmpty && ! isLongitude (valueCandidate! )
797
+ valueCandidate? .isEmpty != false || ! isLongitude (valueCandidate! )
796
798
? errorText ?? FormBuilderLocalizations .current.longitudeErrorText
797
799
: null ;
798
800
@@ -802,7 +804,7 @@ class FormBuilderValidators {
802
804
String ? errorText,
803
805
}) =>
804
806
(valueCandidate) =>
805
- true == valueCandidate? .isNotEmpty && ! isBase64 (valueCandidate! )
807
+ valueCandidate? .isEmpty != false || ! isBase64 (valueCandidate! )
806
808
? errorText ?? FormBuilderLocalizations .current.base64ErrorText
807
809
: null ;
808
810
@@ -812,7 +814,7 @@ class FormBuilderValidators {
812
814
String ? errorText,
813
815
}) =>
814
816
(valueCandidate) =>
815
- true == valueCandidate? .isNotEmpty && ! isFilePath (valueCandidate! )
817
+ valueCandidate? .isEmpty != false || ! isFilePath (valueCandidate! )
816
818
? errorText ?? FormBuilderLocalizations .current.pathErrorText
817
819
: null ;
818
820
@@ -822,7 +824,7 @@ class FormBuilderValidators {
822
824
String ? errorText,
823
825
}) =>
824
826
(valueCandidate) =>
825
- true == valueCandidate? .isNotEmpty && ! isOddNumber (valueCandidate! )
827
+ valueCandidate? .isEmpty != false || ! isOddNumber (valueCandidate! )
826
828
? errorText ?? FormBuilderLocalizations .current.oddNumberErrorText
827
829
: null ;
828
830
@@ -831,7 +833,7 @@ class FormBuilderValidators {
831
833
static FormFieldValidator <String > evenNumber ({
832
834
String ? errorText,
833
835
}) =>
834
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
836
+ (valueCandidate) => valueCandidate? .isEmpty != false ||
835
837
! isEvenNumber (valueCandidate! )
836
838
? errorText ?? FormBuilderLocalizations .current.evenNumberErrorText
837
839
: null ;
@@ -846,7 +848,7 @@ class FormBuilderValidators {
846
848
String ? errorText,
847
849
}) =>
848
850
(valueCandidate) {
849
- if (true == valueCandidate? .isNotEmpty) {
851
+ if (valueCandidate? .isNotEmpty == true ) {
850
852
int ? port = int .tryParse (valueCandidate! );
851
853
if (port == null || port < min || port > max) {
852
854
return errorText ??
@@ -864,7 +866,7 @@ class FormBuilderValidators {
864
866
static FormFieldValidator <String > macAddress ({
865
867
String ? errorText,
866
868
}) =>
867
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
869
+ (valueCandidate) => valueCandidate? .isEmpty != false ||
868
870
! isMACAddress (valueCandidate! )
869
871
? errorText ?? FormBuilderLocalizations .current.macAddressErrorText
870
872
: null ;
@@ -876,7 +878,7 @@ class FormBuilderValidators {
876
878
required String prefix,
877
879
String ? errorText,
878
880
}) =>
879
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
881
+ (valueCandidate) => valueCandidate? .isEmpty != false ||
880
882
! valueCandidate! .startsWith (prefix)
881
883
? errorText ??
882
884
FormBuilderLocalizations .current.startsWithErrorText (prefix)
@@ -889,11 +891,11 @@ class FormBuilderValidators {
889
891
required String suffix,
890
892
String ? errorText,
891
893
}) =>
892
- (valueCandidate) => true == valueCandidate ? .isNotEmpty &&
893
- ! valueCandidate! .endsWith (suffix)
894
- ? errorText ??
895
- FormBuilderLocalizations .current.endsWithErrorText (suffix)
896
- : null ;
894
+ (valueCandidate) =>
895
+ valueCandidate ? .isEmpty != false || ! valueCandidate! .endsWith (suffix)
896
+ ? errorText ??
897
+ FormBuilderLocalizations .current.endsWithErrorText (suffix)
898
+ : null ;
897
899
898
900
/// [FormFieldValidator] that requires the field's value to contains a specific value.
899
901
/// * [substring] is the value that the field's value should contain.
@@ -904,9 +906,8 @@ class FormBuilderValidators {
904
906
bool caseSensitive = true ,
905
907
String ? errorText,
906
908
}) =>
907
- (valueCandidate) => true == valueCandidate? .isNotEmpty &&
908
- caseSensitive &&
909
- ! valueCandidate! .contains (substring) ||
909
+ (valueCandidate) => valueCandidate? .isEmpty != false ||
910
+ caseSensitive && ! valueCandidate! .contains (substring) ||
910
911
! caseSensitive &&
911
912
! valueCandidate!
912
913
.toLowerCase ()
@@ -947,7 +948,7 @@ class FormBuilderValidators {
947
948
String ? errorText,
948
949
}) =>
949
950
(valueCandidate) =>
950
- true == valueCandidate? .isNotEmpty && ! isValidIban (valueCandidate! )
951
+ valueCandidate? .isEmpty != false || ! isValidIban (valueCandidate! )
951
952
? errorText ?? FormBuilderLocalizations .current.ibanErrorText
952
953
: null ;
953
954
}
0 commit comments