@@ -776,194 +776,193 @@ void main() {
776
776
);
777
777
778
778
testWidgets (
779
- 'FormBuilderValidators.alphabetical' ,
780
- (WidgetTester tester) => testValidations (tester, (context) {
781
- final validator = FormBuilderValidators .alphabetical ();
782
- // Pass
783
- expect (validator ('Hello' ), isNull);
784
- expect (validator ('world' ), isNull);
785
- // Fail
786
- expect (validator ('Hello123' ), isNotNull);
787
- expect (validator ('123' ), isNotNull);
788
- expect (validator ('!@#' ), isNotNull);
789
- }),
790
- );
791
-
792
- testWidgets (
793
- 'FormBuilderValidators.uuid' ,
794
- (WidgetTester tester) => testValidations (tester, (context) {
795
- final validator = FormBuilderValidators .uuid ();
796
- // Pass
797
- expect (validator ('123e4567-e89b-12d3-a456-426614174000' ), isNull);
798
- // Fail
799
- expect (validator ('not-a-uuid' ), isNotNull);
800
- }),
801
- );
802
-
803
- testWidgets (
804
- 'FormBuilderValidators.json' ,
805
- (WidgetTester tester) => testValidations (tester, (context) {
806
- final validator = FormBuilderValidators .json ();
807
- // Pass
808
- expect (validator ('{"key": "value"}' ), isNull);
809
- // Fail
810
- expect (validator ('not-json' ), isNotNull);
811
- }),
812
- );
813
-
814
- testWidgets (
815
- 'FormBuilderValidators.latitude' ,
816
- (WidgetTester tester) => testValidations (tester, (context) {
817
- final validator = FormBuilderValidators .latitude ();
818
- // Pass
819
- expect (validator ('45.0' ), isNull);
820
- expect (validator ('-90.0' ), isNull);
821
- // Fail
822
- expect (validator ('91.0' ), isNotNull);
823
- expect (validator ('latitude' ), isNotNull);
824
- }),
825
- );
826
-
827
- testWidgets (
828
- 'FormBuilderValidators.longitude' ,
829
- (WidgetTester tester) => testValidations (tester, (context) {
830
- final validator = FormBuilderValidators .longitude ();
831
- // Pass
832
- expect (validator ('90.0' ), isNull);
833
- expect (validator ('-180.0' ), isNull);
834
- // Fail
835
- expect (validator ('181.0' ), isNotNull);
836
- expect (validator ('longitude' ), isNotNull);
837
- }),
838
- );
839
-
840
- testWidgets (
841
- 'FormBuilderValidators.base64' ,
842
- (WidgetTester tester) => testValidations (tester, (context) {
843
- final validator = FormBuilderValidators .base64 ();
844
- // Pass
845
- expect (validator ('SGVsbG8gd29ybGQ=' ), isNull);
846
- // Fail
847
- expect (validator ('not-base64' ), isNotNull);
848
- }),
849
- );
850
-
851
- testWidgets (
852
- 'FormBuilderValidators.path' ,
853
- (WidgetTester tester) => testValidations (tester, (context) {
854
- final validator = FormBuilderValidators .path ();
855
- // Pass
856
- expect (validator ('/path/to/file' ), isNull);
857
- // Fail
858
- expect (validator ('path\\ to\\ file' ), isNotNull);
859
- }),
860
- );
861
-
862
- testWidgets (
863
- 'FormBuilderValidators.oddNumber' ,
864
- (WidgetTester tester) => testValidations (tester, (context) {
865
- final validator = FormBuilderValidators .oddNumber ();
866
- // Pass
867
- expect (validator ('3' ), isNull);
868
- expect (validator ('5' ), isNull);
869
- // Fail
870
- expect (validator ('2' ), isNotNull);
871
- expect (validator ('4' ), isNotNull);
872
- }),
873
- );
874
-
875
- testWidgets (
876
- 'FormBuilderValidators.evenNumber' ,
877
- (WidgetTester tester) => testValidations (tester, (context) {
878
- final validator = FormBuilderValidators .evenNumber ();
879
- // Pass
880
- expect (validator ('2' ), isNull);
881
- expect (validator ('4' ), isNull);
882
- // Fail
883
- expect (validator ('3' ), isNotNull);
884
- expect (validator ('5' ), isNotNull);
885
- }),
886
- );
887
-
888
- testWidgets (
889
- 'FormBuilderValidators.portNumber' ,
890
- (WidgetTester tester) => testValidations (tester, (context) {
891
- final validator = FormBuilderValidators .portNumber ();
892
- // Pass
893
- expect (validator ('8080' ), isNull);
894
- expect (validator ('80' ), isNull);
895
- // Fail
896
- expect (validator ('70000' ), isNotNull);
897
- expect (validator ('-1' ), isNotNull);
898
- }),
899
- );
900
-
901
- testWidgets (
902
- 'FormBuilderValidators.macAddress' ,
903
- (WidgetTester tester) => testValidations (tester, (context) {
904
- final validator = FormBuilderValidators .macAddress ();
905
- // Pass
906
- expect (validator ('00:1B:44:11:3A:B7' ), isNull);
907
- expect (validator ('00-1B-44-11-3A-B7' ), isNull);
908
- // Fail
909
- expect (validator ('invalid-mac' ), isNotNull);
910
- }),
911
- );
912
-
913
- testWidgets (
914
- 'FormBuilderValidators.startsWith' ,
915
- (WidgetTester tester) => testValidations (tester, (context) {
916
- final validator = FormBuilderValidators .startsWith (prefix: 'Hello' );
917
- // Pass
918
- expect (validator ('Hello world' ), isNull);
919
- // Fail
920
- expect (validator ('world Hello' ), isNotNull);
921
- }),
922
- );
923
-
924
- testWidgets (
925
- 'FormBuilderValidators.endsWith' ,
926
- (WidgetTester tester) => testValidations (tester, (context) {
927
- final validator = FormBuilderValidators .endsWith (suffix: 'world' );
928
- // Pass
929
- expect (validator ('Hello world' ), isNull);
930
- // Fail
931
- expect (validator ('world Hello' ), isNotNull);
932
- }),
933
- );
934
-
935
- testWidgets (
936
- 'FormBuilderValidators.contains' ,
937
- (WidgetTester tester) => testValidations (tester, (context) {
938
- final validator = FormBuilderValidators .contains (substring: 'flutter' );
939
- // Pass
940
- expect (validator ('I love flutter' ), isNull);
941
- // Fail
942
- expect (validator ('I love dart' ), isNotNull);
943
- }),
944
- );
945
-
946
- testWidgets (
947
- 'FormBuilderValidators.between' ,
948
- (WidgetTester tester) => testValidations (tester, (context) {
949
- final validator = FormBuilderValidators .between (min: 10 , max: 20 );
950
- // Pass
951
- expect (validator (15 ), isNull);
952
- // Fail
953
- expect (validator (5 ), isNotNull);
954
- expect (validator (25 ), isNotNull);
955
- }),
956
- );
957
-
958
- testWidgets (
959
- 'FormBuilderValidators.inList' ,
960
- (WidgetTester tester) => testValidations (tester, (context) {
961
- final validator = FormBuilderValidators .inList ([1 , 2 , 3 ]);
962
- // Pass
963
- expect (validator (2 ), isNull);
964
- // Fail
965
- expect (validator (4 ), isNotNull);
966
- }),
967
- );
779
+ 'FormBuilderValidators.alphabetical' ,
780
+ (WidgetTester tester) => testValidations (tester, (context) {
781
+ final validator = FormBuilderValidators .alphabetical ();
782
+ // Pass
783
+ expect (validator ('Hello' ), isNull);
784
+ expect (validator ('world' ), isNull);
785
+ // Fail
786
+ expect (validator ('Hello123' ), isNotNull);
787
+ expect (validator ('123' ), isNotNull);
788
+ expect (validator ('!@#' ), isNotNull);
789
+ }),
790
+ );
968
791
792
+ testWidgets (
793
+ 'FormBuilderValidators.uuid' ,
794
+ (WidgetTester tester) => testValidations (tester, (context) {
795
+ final validator = FormBuilderValidators .uuid ();
796
+ // Pass
797
+ expect (validator ('123e4567-e89b-12d3-a456-426614174000' ), isNull);
798
+ // Fail
799
+ expect (validator ('not-a-uuid' ), isNotNull);
800
+ }),
801
+ );
802
+
803
+ testWidgets (
804
+ 'FormBuilderValidators.json' ,
805
+ (WidgetTester tester) => testValidations (tester, (context) {
806
+ final validator = FormBuilderValidators .json ();
807
+ // Pass
808
+ expect (validator ('{"key": "value"}' ), isNull);
809
+ // Fail
810
+ expect (validator ('not-json' ), isNotNull);
811
+ }),
812
+ );
813
+
814
+ testWidgets (
815
+ 'FormBuilderValidators.latitude' ,
816
+ (WidgetTester tester) => testValidations (tester, (context) {
817
+ final validator = FormBuilderValidators .latitude ();
818
+ // Pass
819
+ expect (validator ('45.0' ), isNull);
820
+ expect (validator ('-90.0' ), isNull);
821
+ // Fail
822
+ expect (validator ('91.0' ), isNotNull);
823
+ expect (validator ('latitude' ), isNotNull);
824
+ }),
825
+ );
826
+
827
+ testWidgets (
828
+ 'FormBuilderValidators.longitude' ,
829
+ (WidgetTester tester) => testValidations (tester, (context) {
830
+ final validator = FormBuilderValidators .longitude ();
831
+ // Pass
832
+ expect (validator ('90.0' ), isNull);
833
+ expect (validator ('-180.0' ), isNull);
834
+ // Fail
835
+ expect (validator ('181.0' ), isNotNull);
836
+ expect (validator ('longitude' ), isNotNull);
837
+ }),
838
+ );
839
+
840
+ testWidgets (
841
+ 'FormBuilderValidators.base64' ,
842
+ (WidgetTester tester) => testValidations (tester, (context) {
843
+ final validator = FormBuilderValidators .base64 ();
844
+ // Pass
845
+ expect (validator ('SGVsbG8gd29ybGQ=' ), isNull);
846
+ // Fail
847
+ expect (validator ('not-base64' ), isNotNull);
848
+ }),
849
+ );
850
+
851
+ testWidgets (
852
+ 'FormBuilderValidators.path' ,
853
+ (WidgetTester tester) => testValidations (tester, (context) {
854
+ final validator = FormBuilderValidators .path ();
855
+ // Pass
856
+ expect (validator ('/path/to/file' ), isNull);
857
+ // Fail
858
+ expect (validator ('path\\ to\\ file' ), isNotNull);
859
+ }),
860
+ );
861
+
862
+ testWidgets (
863
+ 'FormBuilderValidators.oddNumber' ,
864
+ (WidgetTester tester) => testValidations (tester, (context) {
865
+ final validator = FormBuilderValidators .oddNumber ();
866
+ // Pass
867
+ expect (validator ('3' ), isNull);
868
+ expect (validator ('5' ), isNull);
869
+ // Fail
870
+ expect (validator ('2' ), isNotNull);
871
+ expect (validator ('4' ), isNotNull);
872
+ }),
873
+ );
874
+
875
+ testWidgets (
876
+ 'FormBuilderValidators.evenNumber' ,
877
+ (WidgetTester tester) => testValidations (tester, (context) {
878
+ final validator = FormBuilderValidators .evenNumber ();
879
+ // Pass
880
+ expect (validator ('2' ), isNull);
881
+ expect (validator ('4' ), isNull);
882
+ // Fail
883
+ expect (validator ('3' ), isNotNull);
884
+ expect (validator ('5' ), isNotNull);
885
+ }),
886
+ );
887
+
888
+ testWidgets (
889
+ 'FormBuilderValidators.portNumber' ,
890
+ (WidgetTester tester) => testValidations (tester, (context) {
891
+ final validator = FormBuilderValidators .portNumber ();
892
+ // Pass
893
+ expect (validator ('8080' ), isNull);
894
+ expect (validator ('80' ), isNull);
895
+ // Fail
896
+ expect (validator ('70000' ), isNotNull);
897
+ expect (validator ('-1' ), isNotNull);
898
+ }),
899
+ );
900
+
901
+ testWidgets (
902
+ 'FormBuilderValidators.macAddress' ,
903
+ (WidgetTester tester) => testValidations (tester, (context) {
904
+ final validator = FormBuilderValidators .macAddress ();
905
+ // Pass
906
+ expect (validator ('00:1B:44:11:3A:B7' ), isNull);
907
+ expect (validator ('00-1B-44-11-3A-B7' ), isNull);
908
+ // Fail
909
+ expect (validator ('invalid-mac' ), isNotNull);
910
+ }),
911
+ );
912
+
913
+ testWidgets (
914
+ 'FormBuilderValidators.startsWith' ,
915
+ (WidgetTester tester) => testValidations (tester, (context) {
916
+ final validator = FormBuilderValidators .startsWith (prefix: 'Hello' );
917
+ // Pass
918
+ expect (validator ('Hello world' ), isNull);
919
+ // Fail
920
+ expect (validator ('world Hello' ), isNotNull);
921
+ }),
922
+ );
923
+
924
+ testWidgets (
925
+ 'FormBuilderValidators.endsWith' ,
926
+ (WidgetTester tester) => testValidations (tester, (context) {
927
+ final validator = FormBuilderValidators .endsWith (suffix: 'world' );
928
+ // Pass
929
+ expect (validator ('Hello world' ), isNull);
930
+ // Fail
931
+ expect (validator ('world Hello' ), isNotNull);
932
+ }),
933
+ );
934
+
935
+ testWidgets (
936
+ 'FormBuilderValidators.contains' ,
937
+ (WidgetTester tester) => testValidations (tester, (context) {
938
+ final validator = FormBuilderValidators .contains (substring: 'flutter' );
939
+ // Pass
940
+ expect (validator ('I love flutter' ), isNull);
941
+ // Fail
942
+ expect (validator ('I love dart' ), isNotNull);
943
+ }),
944
+ );
945
+
946
+ testWidgets (
947
+ 'FormBuilderValidators.between' ,
948
+ (WidgetTester tester) => testValidations (tester, (context) {
949
+ final validator = FormBuilderValidators .between (min: 10 , max: 20 );
950
+ // Pass
951
+ expect (validator (15 ), isNull);
952
+ // Fail
953
+ expect (validator (5 ), isNotNull);
954
+ expect (validator (25 ), isNotNull);
955
+ }),
956
+ );
957
+
958
+ testWidgets (
959
+ 'FormBuilderValidators.inList' ,
960
+ (WidgetTester tester) => testValidations (tester, (context) {
961
+ final validator = FormBuilderValidators .inList ([1 , 2 , 3 ]);
962
+ // Pass
963
+ expect (validator (2 ), isNull);
964
+ // Fail
965
+ expect (validator (4 ), isNotNull);
966
+ }),
967
+ );
969
968
}
0 commit comments