Skip to content

Commit 806c635

Browse files
committed
chore: release form_builder_validators v8.0.0
1 parent 5dcdcf5 commit 806c635

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

packages/form_builder_validators/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [8.0.0] - 10-Apr-2022
2+
**BREAKING CHANGE**:
3+
* Avoid passing context to validator functions.
4+
5+
* Added Swahili (sw) language support
6+
7+
18
## [7.9.0] - 04-Apr-2022
29
* Added Bangla (bn) language support
310

packages/form_builder_validators/README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# FormBuilder Validators
22

3-
Form Builder Validators provide a convenient way of validating data entered into any Flutter FormField. It provides common validation rules out of box (such as required, email, number, min, max, minLength, maxLength, date validations etc.) as well as a way to compose multiple validation rules into one FormFieldValidator.
3+
Form Builder Validators provide a convenient way of validating data entered into any Flutter FormField. It offers common validation rules out of the box (such as required, email, number, min, max, minLength, maxLength, date validations, etc.) and a way to compose multiple validation rules into one FormFieldValidator.
44

5-
Also included is the `l10n` / `i18n` of error text messages into multiple languages
5+
Also included is the `l10n` / `i18n` of error text messages to multiple languages.
66
___
77

88
[![Pub Version](https://img.shields.io/pub/v/form_builder_validators?logo=flutter&style=for-the-badge)](https://pub.dev/packages/form_builder_validators)
@@ -15,6 +15,9 @@ ___
1515
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-1.svg)](https://www.buymeacoffee.com/danvick)
1616
___
1717

18+
> ### Migrating from version 7 to 8
19+
> To migrate from v7 to v8, remove `context` as a parameter to validator functions. For example, `FormBuilderValidators.required(context)` becomes `FormBuilderValidators.required()` without context passed to it.
20+
1821
### Example
1922
```dart
2023
import 'package:form_builder_validators/form_builder_validators.dart';
@@ -24,15 +27,15 @@ import 'package:form_builder_validators/form_builder_validators.dart';
2427
TextFormField(
2528
decoration: InputDecoration(labelText: 'Name'),
2629
autovalidateMode: AutovalidateMode.always,
27-
validator: FormBuilderValidators.required(context),
30+
validator: FormBuilderValidators.required(),
2831
),
2932
TextFormField(
3033
decoration: InputDecoration(labelText: 'Age'),
3134
keyboardType: TextInputType.number,
3235
autovalidateMode: AutovalidateMode.always,
3336
validator: FormBuilderValidators.compose([
34-
FormBuilderValidators.numeric(context, errorText: 'La edad debe ser numérica.'),
35-
FormBuilderValidators.max(context, 70),
37+
FormBuilderValidators.numeric(errorText: 'La edad debe ser numérica.'),
38+
FormBuilderValidators.max(70),
3639
(val) {
3740
var number = int.tryParse(val ?? '');
3841
if (number != null) if (number < 0)
@@ -45,7 +48,7 @@ TextFormField(
4548

4649
## Built-in Validators
4750
This package comes with several most common `FormFieldValidator`s such as required, numeric, mail,
48-
URL, min, max, minLength, maxLength, IP, credit card etc. with default `errorText` messages.
51+
URL, min, max, minLength, maxLength, IP, credit card, etc., with default `errorText` messages.
4952

5053
Available built-in validators include:
5154
* `FormBuilderValidators.creditCard()` - requires the field's value to be a valid credit card number.
@@ -64,10 +67,9 @@ Available built-in validators include:
6467
* ``FormBuilderValidators.url()`` - requires the field's value to be a valid url.
6568

6669
## Composing multiple validators
67-
`FormBuilderValidators` class comes with a very useful static function named `compose()` which takes a list of `FormFieldValidator` functions. This allows you to create once and reuse validation rules across multiple fields, widgets or apps.
70+
`FormBuilderValidators` class comes with a very useful static function named `compose()` which takes a list of `FormFieldValidator` functions. Composing allows you to create once and reuse validation rules across multiple fields, widgets, or apps.
6871

69-
On validation each validator is run and if any one returns a non-null value (i.e. a String), validation fails and the `errorText` for the field is set as the
70-
returned string.
72+
On validation, each validator is run, and if any one validator returns a non-null value (i.e., a String), validation fails, and the `errorText` for the field is set as the returned string.
7173

7274
Example:
7375
```dart
@@ -77,17 +79,16 @@ TextFormField(
7779
autovalidateMode: AutovalidateMode.always,
7880
validator: FormBuilderValidators.compose([
7981
/// Makes this field required
80-
FormBuilderValidators.required(context),
82+
FormBuilderValidators.required(),
8183
8284
/// Ensures the value entered is numeric - with custom error message
83-
FormBuilderValidators.numeric(context,
84-
errorText: 'La edad debe ser numérica.'),
85+
FormBuilderValidators.numeric(errorText: 'La edad debe ser numérica.'),
8586
8687
/// Sets a maximum value of 70
87-
FormBuilderValidators.max(context, 70),
88+
FormBuilderValidators.max(70),
8889
8990
/// Include your own custom `FormFieldValidator` function, if you want
90-
/// Ensures positive values only. We could also have used `FormBuilderValidators.min(context, 0)` instead
91+
/// Ensures positive values only. We could also have used `FormBuilderValidators.min(0)` instead
9192
(val) {
9293
final number = int.tryParse(val);
9394
if (number == null) return null;
@@ -144,31 +145,31 @@ To allow for localization of default error messages within your app, add `FormBu
144145
- Swahili (sw)
145146
- Ukrainian (uk)
146147

147-
and you can still add your own custom error messages.
148+
And you can still add your custom error messages.
148149

149150
## Support
150151
### Issues and PRs
151-
Any kind of support in the form of reporting bugs, answering questions or PRs is always appreciated.
152+
Any support in reporting bugs, answering questions, or PRs is always appreciated.
152153

153154
We especially welcome efforts to internationalize/localize the package by translating the default validation `errorText` strings for built-in validation rules.
154155

155156
### Localizing messages
156157

157158
#### 1. Add ARB files
158-
Create one ARB file inside the `lib/l10n` folder for each of the locales you need to add support for. Name the files in the following way: `intl_<LOCALE_ISO_CODE>.arb`. For example: `intl_fr.arb` or `intl_fr_FR.arb`.
159+
Create one ARB file inside the `lib/l10n` folder for each of the locales you need to add support. Name the files in the following way: `intl_<LOCALE_ISO_CODE>.arb`. For example: `intl_fr.arb` or `intl_fr_FR.arb`.
159160

160161
#### 2. Translate the error messages
161162

162-
Duplicate the contents of `intl_messages.arb` (or any other ARB file) into your newly created ARB file then translate the error messages by overwritting the default messages.
163+
Duplicate the contents of `intl_messages.arb` (or any other ARB file) into your newly created ARB file, then translate the error messages by overwriting the default messages.
163164

164165
#### 3. Run command
165-
To generate boilerplate code for localization, run the generate command inside package directory where `pubspec.yaml` file is located:
166+
To generate boilerplate code for localization, run the generate command inside the package directory where `pubspec.yaml` file is located:
166167

167168
```
168169
flutter pub run intl_utils:generate
169170
```
170171

171-
This will automagically create/update files inside `lib/localization` directory which will include support for your newly added locale.
172+
Running the command will automatically create/update files inside the `lib/localization` directory, including your newly added locale support.
172173

173174
#### 4. Update README
174175
Remember to update README, adding the new language (and language code) under [Supported languages section](#supported-languages-default-errortext-messages) so that everyone knows your new language is now supported!
@@ -177,8 +178,7 @@ Remember to update README, adding the new language (and language code) under [Su
177178
Submit your PR and be of help to millions of developers all over the world!
178179

179180
### Coffee :-)
180-
If this package was helpful to you in delivering your project or you just wanna to support this
181-
package, a cup of coffee would be highly appreciated ;-)
181+
If this package was helpful to you in delivering your project, or you want to support this package, I would highly appreciate a cup of coffee ;-)
182182

183183
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-1.svg)](https://www.buymeacoffee.com/danvick)
184184

packages/form_builder_validators/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: form_builder_validators
22
description: This package provides common reusable FormFieldValidators for Flutter FormField widgets with internationalization
3-
version: 7.9.0
3+
version: 8.0.0
44
homepage: https://github.com/danvick/flutter_form_builder
55

66
environment:

0 commit comments

Comments
 (0)