Skip to content

Commit b3dab78

Browse files
committed
Add more test coverage
1 parent 995b030 commit b3dab78

32 files changed

+983
-84
lines changed

analysis_options.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ linter:
1010
always_use_package_imports: false
1111
always_specify_types: true
1212
omit_local_variable_types: false
13-
public_member_api_docs: true
13+
public_member_api_docs: true
14+
directives_ordering: true
15+

lib/l10n/intl_en.arb

Lines changed: 206 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,89 @@
44
"dateStringErrorText": "This field requires a valid date string.",
55
"emailErrorText": "This field requires a valid email address.",
66
"equalErrorText": "This field value must be equal to {value}.",
7-
"equalLengthErrorText": "Value must have a length equal to {length}",
7+
"@equalErrorText": {
8+
"placeholders": {
9+
"value": {
10+
"type": "String",
11+
"description": "The value that the field must equal"
12+
}
13+
}
14+
},
15+
"equalLengthErrorText": "Value must have a length equal to {length}.",
16+
"@equalLengthErrorText": {
17+
"placeholders": {
18+
"length": {
19+
"type": "int",
20+
"description": "The exact length the value must have"
21+
}
22+
}
23+
},
824
"integerErrorText": "This field requires a valid integer.",
925
"ipErrorText": "This field requires a valid IP.",
1026
"matchErrorText": "Value does not match pattern.",
11-
"maxErrorText": "Value must be less than or equal to {max}",
12-
"maxLengthErrorText": "Value must have a length less than or equal to {maxLength}",
13-
"maxWordsCountErrorText": "Value must have a words count less than or equal to {maxWordsCount}",
14-
"minErrorText": "Value must be greater than or equal to {min}",
15-
"minLengthErrorText": "Value must have a length greater than or equal to {minLength}",
16-
"minWordsCountErrorText": "Value must have a words count greater than or equal to {minWordsCount}",
27+
"maxErrorText": "Value must be less than or equal to {max}.",
28+
"@maxErrorText": {
29+
"placeholders": {
30+
"max": {
31+
"type": "num",
32+
"description": "The maximum value allowed"
33+
}
34+
}
35+
},
36+
"maxLengthErrorText": "Value must have a length less than or equal to {maxLength}.",
37+
"@maxLengthErrorText": {
38+
"placeholders": {
39+
"maxLength": {
40+
"type": "int",
41+
"description": "The maximum length allowed"
42+
}
43+
}
44+
},
45+
"maxWordsCountErrorText": "Value must have a words count less than or equal to {maxWordsCount}.",
46+
"@maxWordsCountErrorText": {
47+
"placeholders": {
48+
"maxWordsCount": {
49+
"type": "int",
50+
"description": "The maximum word count allowed"
51+
}
52+
}
53+
},
54+
"minErrorText": "Value must be greater than or equal to {min}.",
55+
"@minErrorText": {
56+
"placeholders": {
57+
"min": {
58+
"type": "num",
59+
"description": "The minimum value allowed"
60+
}
61+
}
62+
},
63+
"minLengthErrorText": "Value must have a length greater than or equal to {minLength}.",
64+
"@minLengthErrorText": {
65+
"placeholders": {
66+
"minLength": {
67+
"type": "int",
68+
"description": "The minimum length required"
69+
}
70+
}
71+
},
72+
"minWordsCountErrorText": "Value must have a words count greater than or equal to {minWordsCount}.",
73+
"@minWordsCountErrorText": {
74+
"placeholders": {
75+
"minWordsCount": {
76+
"type": "int",
77+
"description": "The minimum word count required"
78+
}
79+
}
80+
},
1781
"notEqualErrorText": "This field value must not be equal to {value}.",
82+
"@notEqualErrorText": {
83+
"placeholders": {
84+
"value": {
85+
"type": "String",
86+
"description": "The value that the field must not equal"
87+
}
88+
}
89+
},
1890
"numericErrorText": "Value must be numeric.",
1991
"requiredErrorText": "This field cannot be empty.",
2092
"urlErrorText": "This field requires a valid URL address.",
@@ -23,17 +95,93 @@
2395
"creditCardExpiredErrorText": "This credit card has expired.",
2496
"creditCardCVCErrorText": "This field requires a valid CVC code.",
2597
"colorCodeErrorText": "Value should be a valid {colorCode} color code.",
98+
"@colorCodeErrorText": {
99+
"placeholders": {
100+
"colorCode": {
101+
"type": "String",
102+
"description": "The type of color code (e.g., HEX, RGB)"
103+
}
104+
}
105+
},
26106
"uppercaseErrorText": "Value must be uppercase.",
27107
"lowercaseErrorText": "Value must be lowercase.",
28-
"fileExtensionErrorText": "File extension must be {extensions}",
29-
"fileSizeErrorText": "File size must be less than {maxSize} while it is {fileSize}",
30-
"dateRangeErrorText": "Date must be in range {min} - {max}",
108+
"fileExtensionErrorText": "File extension must be {extensions}.",
109+
"@fileExtensionErrorText": {
110+
"placeholders": {
111+
"extensions": {
112+
"type": "String",
113+
"description": "Allowed file extensions"
114+
}
115+
}
116+
},
117+
"fileSizeErrorText": "File size must be less than {maxSize} while it is {fileSize}.",
118+
"@fileSizeErrorText": {
119+
"placeholders": {
120+
"maxSize": {
121+
"type": "String",
122+
"description": "The maximum file size allowed"
123+
},
124+
"fileSize": {
125+
"type": "String",
126+
"description": "The actual file size"
127+
}
128+
}
129+
},
130+
"dateRangeErrorText": "Date must be in range {min} - {max}.",
131+
"@dateRangeErrorText": {
132+
"placeholders": {
133+
"min": {
134+
"type": "DateTime",
135+
"format": "yMd",
136+
"example": "11/10/2021",
137+
"description": "The minimum date allowed"
138+
},
139+
"max": {
140+
"type": "DateTime",
141+
"format": "yMd",
142+
"example": "11/10/2021",
143+
"description": "The maximum date allowed"
144+
}
145+
}
146+
},
31147
"mustBeTrueErrorText": "This field must be true.",
32148
"mustBeFalseErrorText": "This field must be false.",
33149
"containsSpecialCharErrorText": "Value must contain at least {min} special characters.",
150+
"@containsSpecialCharErrorText": {
151+
"placeholders": {
152+
"min": {
153+
"type": "int",
154+
"description": "The minimum number of special characters required"
155+
}
156+
}
157+
},
34158
"containsUppercaseCharErrorText": "Value must contain at least {min} uppercase characters.",
159+
"@containsUppercaseCharErrorText": {
160+
"placeholders": {
161+
"min": {
162+
"type": "int",
163+
"description": "The minimum number of uppercase characters required"
164+
}
165+
}
166+
},
35167
"containsLowercaseCharErrorText": "Value must contain at least {min} lowercase characters.",
168+
"@containsLowercaseCharErrorText": {
169+
"placeholders": {
170+
"min": {
171+
"type": "int",
172+
"description": "The minimum number of lowercase characters required"
173+
}
174+
}
175+
},
36176
"containsNumberErrorText": "Value must contain at least {min} numbers.",
177+
"@containsNumberErrorText": {
178+
"placeholders": {
179+
"min": {
180+
"type": "int",
181+
"description": "The minimum number of numerical characters required"
182+
}
183+
}
184+
},
37185
"alphabeticalErrorText": "Value must be alphabetical.",
38186
"uuidErrorText": "Value must be a valid UUID.",
39187
"jsonErrorText": "Value must be valid JSON.",
@@ -44,11 +192,59 @@
44192
"oddNumberErrorText": "Value must be an odd number.",
45193
"evenNumberErrorText": "Value must be an even number.",
46194
"portNumberErrorText": "Value must be a valid port number between {min} and {max}.",
195+
"@portNumberErrorText": {
196+
"placeholders": {
197+
"min": {
198+
"type": "int",
199+
"description": "The minimum port number allowed"
200+
},
201+
"max": {
202+
"type": "int",
203+
"description": "The maximum port number allowed"
204+
}
205+
}
206+
},
47207
"macAddressErrorText": "Value must be a valid MAC address.",
48208
"startsWithErrorText": "Value must start with {value}.",
209+
"@startsWithErrorText": {
210+
"placeholders": {
211+
"value": {
212+
"type": "String",
213+
"description": "The value that the field must start with"
214+
}
215+
}
216+
},
49217
"endsWithErrorText": "Value must end with {value}.",
218+
"@endsWithErrorText": {
219+
"placeholders": {
220+
"value": {
221+
"type": "String",
222+
"description": "The value that the field must end with"
223+
}
224+
}
225+
},
50226
"containsErrorText": "Value must contain {value}.",
227+
"@containsErrorText": {
228+
"placeholders": {
229+
"value": {
230+
"type": "String",
231+
"description": "The value that the field must contain"
232+
}
233+
}
234+
},
51235
"betweenErrorText": "Value must be between {min} and {max}.",
236+
"@betweenErrorText": {
237+
"placeholders": {
238+
"min": {
239+
"type": "num",
240+
"description": "The minimum value allowed"
241+
},
242+
"max": {
243+
"type": "num",
244+
"description": "The maximum value allowed"
245+
}
246+
}
247+
},
52248
"containsElementErrorText": "Value must be in list.",
53249
"ibanErrorText": "Value must be a valid IBAN.",
54250
"uniqueErrorText": "Value must be unique.",

lib/src/core/aggregate_validator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/widgets.dart';
22

3-
import '../../localization/l10n.dart';
43
import '../base_validator.dart';
54

65
/// {@template aggregate_validator_template}
@@ -19,9 +18,10 @@ class AggregateValidator<T> extends BaseValidator<T> {
1918
/// The list of validators to apply to the value.
2019
final List<FormFieldValidator<T>> validators;
2120

21+
// coverage:ignore-start
2222
@override
23-
String get translatedErrorText =>
24-
FormBuilderLocalizations.current.requiredErrorText;
23+
String get translatedErrorText => '';
24+
// coverage:ignore-end
2525

2626
@override
2727
String? validate(T? valueCandidate) {

lib/src/core/compose_validator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/widgets.dart';
22

3-
import '../../localization/l10n.dart';
43
import '../base_validator.dart';
54

65
/// {@template compose_validator_template}
@@ -20,9 +19,10 @@ class ComposeValidator<T> extends BaseValidator<T> {
2019
/// The list of validators to apply to the value.
2120
final List<FormFieldValidator<T>> validators;
2221

22+
// coverage:ignore-start
2323
@override
24-
String get translatedErrorText =>
25-
FormBuilderLocalizations.current.requiredErrorText;
24+
String get translatedErrorText => '';
25+
// coverage:ignore-end
2626

2727
@override
2828
String? validate(T? valueCandidate) {

lib/src/core/conditional_validator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/widgets.dart';
22

3-
import '../../localization/l10n.dart';
43
import '../base_validator.dart';
54

65
/// {@template conditional_validator_template}
@@ -26,9 +25,10 @@ class ConditionalValidator<T> extends BaseValidator<T> {
2625
/// The validator to apply if the condition is met.
2726
final FormFieldValidator<T> validator;
2827

28+
// coverage:ignore-start
2929
@override
30-
String get translatedErrorText =>
31-
FormBuilderLocalizations.current.requiredErrorText;
30+
String get translatedErrorText => '';
31+
// coverage:ignore-end
3232

3333
@override
3434
String? validate(T? valueCandidate) {

lib/src/core/default_value_validator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/widgets.dart';
22

3-
import '../../localization/l10n.dart';
43
import '../base_validator.dart';
54

65
/// {@template default_value_validator_template}
@@ -24,9 +23,10 @@ class DefaultValueValidator<T> extends BaseValidator<T> {
2423
/// The validator to apply to the value or the default value.
2524
final FormFieldValidator<T> validator;
2625

26+
// coverage:ignore-start
2727
@override
28-
String get translatedErrorText =>
29-
FormBuilderLocalizations.current.requiredErrorText;
28+
String get translatedErrorText => '';
29+
// coverage:ignore-end
3030

3131
@override
3232
String? validate(T? valueCandidate) {

lib/src/core/equal_validator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class EqualValidator<T> extends BaseValidator<T> {
2727

2828
@override
2929
String get translatedErrorText =>
30-
FormBuilderLocalizations.current.equalErrorText(value);
30+
FormBuilderLocalizations.current.equalErrorText(value.toString());
3131

3232
@override
3333
String? validateValue(T valueCandidate) {

lib/src/core/not_equal_validator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class NotEqualValidator<T> extends BaseValidator<T> {
2727

2828
@override
2929
String get translatedErrorText =>
30-
FormBuilderLocalizations.current.notEqualErrorText(value);
30+
FormBuilderLocalizations.current.notEqualErrorText(value.toString());
3131

3232
@override
3333
String? validateValue(T valueCandidate) {

lib/src/core/or_validator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/widgets.dart';
22

3-
import '../../localization/l10n.dart';
43
import '../base_validator.dart';
54

65
/// {@template or_validator_template}
@@ -20,9 +19,10 @@ class OrValidator<T> extends BaseValidator<T> {
2019
/// The list of validators to apply to the value.
2120
final List<FormFieldValidator<T>> validators;
2221

22+
// coverage:ignore-start
2323
@override
24-
String get translatedErrorText =>
25-
FormBuilderLocalizations.current.requiredErrorText;
24+
String get translatedErrorText => '';
25+
// coverage:ignore-end
2626

2727
@override
2828
String? validate(T? valueCandidate) {

0 commit comments

Comments
 (0)