Skip to content

Commit d5c5ceb

Browse files
add other sections: collection, datetime, generic types, numeric,
1 parent 74dbe1a commit d5c5ceb

File tree

5 files changed

+192
-189
lines changed

5 files changed

+192
-189
lines changed

README-updated.md

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Also it includes the `l10n` / `i18n` of error text messages to multiple language
1919

2020
- [Features](#features)
2121
- [Validators](#validators)
22-
- [Bool validators](#bool-validators)
2322
- [Collection validators](#collection-validators)
2423
- [Core validators](#core-validators)
2524
- [Datetime validators](#datetime-validators)
@@ -64,19 +63,13 @@ This package comes with several most common `FormFieldValidator`s such as requir
6463
URL, min, max, minLength, maxLength, minWordsCount, maxWordsCount, IP, credit card, etc., with default `errorText` messages.
6564

6665

67-
### Bool validators
68-
69-
- `FormBuilderValidators.isFalse()` - requires the field's to be false.
70-
- `FormBuilderValidators.isTrue()` - requires the field's to be true.
7166

7267
### Collection validators
7368

74-
- `FormBuilderValidators.containsElement()` - requires the field's to be in the provided list.
75-
- `FormBuilderValidators.equalLength()` - requires the length of the field's value to be equal to the provided minimum length.
76-
- `FormBuilderValidators.maxLength()` - requires the length of the field's value to be less than or equal to the provided maximum size.
77-
- `FormBuilderValidators.minLength()` - requires the length of the field's value to be greater than or equal to the provided minimum length.
78-
- `FormBuilderValidators.range()` - requires the field's to be within a range.
79-
- `FormBuilderValidators.unique()` - requires the field's to be unique in the provided list.
69+
- `Validators.equalLength(expectedLength)`: Checks if the field contains a collection (must be a `String`, `Iterable`, or `Map`) with length equals `expectedLength`.
70+
- `Validators.minLength(min)`: Checks if the field contains a collection (must be a `String`, `Iterable`, or `Map`) with length greater than or equal to `min`.
71+
- `Validators.maxLength(max)`: Checks if the field contains a collection (must be a `String`, `Iterable`, or `Map`) with length less than or equal to `max`.
72+
- `Validators.betweenLength(min, max)`: Checks if the field contains a collection (must be a `String`, `Iterable`, or `Map`) with length between `min` and `max`, inclusive.
8073

8174
### Core validators
8275

@@ -94,13 +87,12 @@ URL, min, max, minLength, maxLength, minWordsCount, maxWordsCount, IP, credit ca
9487

9588
### Datetime validators
9689

97-
- `FormBuilderValidators.dateFuture()` - requires the field's value to be in the future.
98-
- `FormBuilderValidators.datePast()` - requires the field's value to be a in the past.
99-
- `FormBuilderValidators.dateRange()` - requires the field's value to be a within a date range.
100-
- `FormBuilderValidators.dateTime()` - requires the field's value to be a valid date time.
101-
- `FormBuilderValidators.date()` - requires the field's value to be a valid date string.
102-
- `FormBuilderValidators.time()` - requires the field's value to be a valid time string.
103-
- `FormBuilderValidators.timeZone()` - requires the field's value to be a valid time zone.
90+
- `Validators.isAfter(reference)`: Checks if the field contains a `DateTime` that is after `reference`.
91+
- `Validators.isBefore(reference)`: Checks if the field contains a `DateTime` that is before `reference`.
92+
- `Validators.isDateTimeBetween(minReference, maxReference)`: Checks if the field contains a `DateTime` that is after `minReference` and before `maxReference`.
93+
- TODO `FormBuilderValidators.date()` - requires the field's value to be a valid date string.
94+
- TODO `FormBuilderValidators.time()` - requires the field's value to be a valid time string.
95+
- TODO `FormBuilderValidators.timeZone()` - requires the field's value to be a valid time zone.
10496

10597
### File validators
10698

@@ -118,6 +110,13 @@ URL, min, max, minLength, maxLength, minWordsCount, maxWordsCount, IP, credit ca
118110
- `Validators.creditCard()`: Checks if the field contains a valid credit card number.
119111
- TODO `FormBuilderValidators.iban()` - requires the field's to be a valid IBAN.
120112

113+
### Generic Type Validators
114+
Validators that check a generic type user input.
115+
116+
- `Validators.isInList(values)`: Checks if the field contains a value that is in the list `values`.
117+
- `Validators.isTrue()`: Checks if the field contains a boolean or a parsable `String` of the `true` value.
118+
- `Validators.isFalse()`: Checks if the field contains a boolean or a parsable `String` of the `false` value.
119+
121120
### Identity validators
122121

123122
- `FormBuilderValidators.city()` - requires the field's value to be a valid city name.
@@ -143,17 +142,20 @@ URL, min, max, minLength, maxLength, minWordsCount, maxWordsCount, IP, credit ca
143142

144143
### Numeric validators
145144

146-
- `FormBuilderValidators.between()` - requires the field's to be between two numbers.
147-
- `FormBuilderValidators.evenNumber()` - requires the field's to be an even number.
148-
- `FormBuilderValidators.integer()` - requires the field's value to be an integer.
149-
- `FormBuilderValidators.max()` - requires the field's value to be less than or equal to the provided number.
150-
- `FormBuilderValidators.min()` - requires the field's value to be greater than or equal to the provided number.
151-
- `FormBuilderValidators.negativeNumber()` - requires the field's to be a negative number.
152-
- `FormBuilderValidators.notZeroNumber()` - requires the field's to be not a number zero.
153-
- `FormBuilderValidators.numeric()` - requires the field's value to be a valid number.
154-
- `FormBuilderValidators.oddNumber()` - requires the field's to be an odd number.
155-
- `FormBuilderValidators.positiveNumber()` - requires the field's to be a positive number.
156-
- `FormBuilderValidators.prime()` - requires the field's to be a prime number.
145+
- `Validators.between(min, max)`: Checks if the field contains a number that is in the range [min, max].
146+
- `Validators.greaterThan(reference)`: Checks if the field contains a number that is greater than `reference`.
147+
- `Validators.greaterThanOrEqualTo(reference)`: Checks if the field contains a number that is greater than or equal to `reference`.
148+
- `Validators.lessThan(reference)`: Checks if the field contains a number that is less than `reference`.
149+
- `Validators.lessThanOrEqualTo(reference)`: Checks if the field contains a number that is less than or equal to `reference`.
150+
- TODO `FormBuilderValidators.evenNumber()` - requires the field's to be an even number.
151+
- TODO `FormBuilderValidators.negativeNumber()` - requires the field's to be a negative number.
152+
- TODO `FormBuilderValidators.notZeroNumber()` - requires the field's to be not a number zero.
153+
- TODO `FormBuilderValidators.oddNumber()` - requires the field's to be an odd number.
154+
- TODO `FormBuilderValidators.positiveNumber()` - requires the field's to be a positive number.
155+
- TODO `FormBuilderValidators.prime()` - requires the field's to be a prime number.
156+
157+
### Path Validators
158+
- `Validators.matchesAllowedExtensions(extensions)`: Checks if the field contains a `String` that is in the list `extensions`.
157159

158160
### String validators
159161

@@ -174,6 +176,9 @@ URL, min, max, minLength, maxLength, minWordsCount, maxWordsCount, IP, credit ca
174176
- TODO `FormBuilderValidators.minWordsCount()` - requires the word count of the field's value to be greater than or equal to the provided minimum count.
175177
- TODO `FormBuilderValidators.singleLine()` - requires the field's string to be a single line of text.
176178

179+
### Type Validators
180+
- `Validators. TODO checkpoint`
181+
177182
### User Information validators
178183

179184
- `Validators.email()`: Checks if the field contains a valid email.

example/lib/forms_with_validate_granularlly.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ class _BodyState extends State<_Body> {
181181
child: Text('Invalid option 2'),
182182
),
183183
]).toList(),
184-
validator: V.isRequired(V.containsElement(
185-
validBloodTypeOptions,
186-
containsElementMsg: (_, List<String> v) =>
184+
validator: V.isRequired(V.isInList(validBloodTypeOptions,
185+
isInListMsg: (_, List<String> v) =>
187186
'The option must be one of: ${v.join(', ')}.')),
188187
onChanged: (String? value) {
189188
setState(() {

0 commit comments

Comments
 (0)