File tree Expand file tree Collapse file tree 4 files changed +23
-1
lines changed Expand file tree Collapse file tree 4 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 12
12
* Add notMatch
13
13
* Add range
14
14
* Add date range
15
+ * Add must be true
16
+ * Add must be false
15
17
16
18
## 10.0.2
17
19
* Reland generated l10n files
Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ Available built-in validators include:
75
75
- ` FormBuilderValidators.lowercase() ` - requires the field's value to be lowercase.
76
76
- ` FormBuilderValidators.fileExtension() ` - requires the field's value to a valid file extension.
77
77
- ` FormBuilderValidators.fileSize() ` - requires the field's to be less than the max size.
78
+ - ` FormBuilderValidators.mustBeTrue() ` - requires the field's to be true.
79
+ - ` FormBuilderValidators.mustBeFalse() ` - requires the field's to be false.
78
80
79
81
### Supported languages
80
82
Original file line number Diff line number Diff line change 27
27
"lowercaseErrorText": "Value must be lowercase.",
28
28
"fileExtensionErrorText": "File extension must be {extensions}",
29
29
"fileSizeErrorText": "File size must be less than {maxSize} while it is {fileSize}",
30
- "dateRangeErrorText": "Date must be in range {min} - {max}"
30
+ "dateRangeErrorText": "Date must be in range {min} - {max}",
31
+ "mustBeTrueErrorText": "This field must be true.",
32
+ "mustBeFalseErrorText": "This field must be false."
31
33
}
Original file line number Diff line number Diff line change @@ -496,4 +496,20 @@ class FormBuilderValidators {
496
496
],
497
497
);
498
498
}
499
+
500
+ /// [FormFieldValidator] that requires the field's value to be a bool and true.
501
+ static FormFieldValidator <bool > mustBeTrue ({
502
+ String ? errorText,
503
+ }) =>
504
+ (valueCandidate) => valueCandidate != true
505
+ ? errorText ?? FormBuilderLocalizations .current.mustBeTrueErrorText
506
+ : null ;
507
+
508
+ /// [FormFieldValidator] that requires the field's value to be a bool and false.
509
+ static FormFieldValidator <bool > mustBeFalse ({
510
+ String ? errorText,
511
+ }) =>
512
+ (valueCandidate) => valueCandidate != false
513
+ ? errorText ?? FormBuilderLocalizations .current.mustBeFalseErrorText
514
+ : null ;
499
515
}
You can’t perform that action at this time.
0 commit comments