You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -330,7 +335,6 @@ On validation, each validator is run, and if any validator returns a non-null va
330
335
331
336
Example:
332
337
333
-
TODO update this example (checkpoint)
334
338
```Dart
335
339
TextFormField(
336
340
decoration: InputDecoration(labelText: 'Age'),
@@ -362,6 +366,11 @@ see [override_form_builder_localizations_en](example/lib/override_form_builder_l
362
366
363
367
## Migrations
364
368
369
+
### v11 to v12
370
+
- Deprecate `FormBuilderValidators` class with its static methods as validators.
371
+
- Instead, you should use `Validators` class.
372
+
TODO implement the remaining of breaking changes
373
+
365
374
### v10 to v11
366
375
367
376
- All validators now first check for null or empty value and return an error if so. You can set `checkNullOrEmpty` to `false` if you want to avoid this behavior.
@@ -373,7 +382,7 @@ see [override_form_builder_localizations_en](example/lib/override_form_builder_l
373
382
Remove `context` as a parameter to validator functions. For example, `FormBuilderValidators.required(context)` becomes `FormBuilderValidators.required()` without `context` passed in.
374
383
375
384
## How this package works
376
-
This package comes with several most common `FormFieldValidator`s such as required, numeric, mail,
385
+
This package comes with several most common `Validator`s and `FormFieldValidator`s such as required, numeric, mail,
@@ -476,11 +485,74 @@ We welcome efforts to internationalize/localize the package by translating the d
476
485
477
486
#### Add new validator
478
487
479
-
1. Add a new validator to one of the folders in the `src` folder.
480
-
2. Implement it using the `BaseValidator` or `TranslatedValidator` class. Override the `validateValue` method and let the base class handle the null check in the `validate` method.
481
-
3. When using a `TranslatedValidator, Override the `translatedErrorText` property and return the correct translation from `FormBuilderLocalizations.current.`.
482
-
4. Make sure to pass `errorText` and `checkNullOrEmpty` to the base class.
483
-
5. Add static method to `form_builder_validators.dart` that uses the new validator.
488
+
1. Add a new validator to one of the folders in the `src/validators` folder.
489
+
2. Implement it as a function which returns `Validator<T>` with `T` being the type of
490
+
the user input to be validated.
491
+
3. Add the @macro tag for documentation using the template name: `validator_<validator_snake_case_name>`.
492
+
This will refer to the actual documentation, which will be on the `Validators` static method.
493
+
4. If your validator uses localized error message, you can use `FormBuilderLocalizations.current.<name_of_localized_message>`
494
+
Next we have the example of the numeric validator `greaterThan`. As we can see, it has its `@macro` docstring, it uses a
495
+
localized error message (`FormBuilderLocalizations.current.greaterThanErrorText(reference)`) and it returns
0 commit comments