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
[](https://www.buymeacoffee.com/danvick)
15
13
___
16
14
17
15
> ### Migrating from version 7 to 8
18
16
> 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.
@@ -61,12 +54,85 @@ Available built-in validators include:
61
54
*`FormBuilderValidators.maxLength()` - requires the length of the field's value to be less than or equal to the provided maximum length.
62
55
*`FormBuilderValidators.min()` - requires the field's value to be greater than or equal to the provided number.
63
56
*`FormBuilderValidators.minLength()` - requires the length of the field's value to be greater than or equal to the provided minimum length.
64
-
*``FormBuilderValidators.equalLength()`` - requires the length of the field's value to be equal to the provided minimum length.
57
+
*`FormBuilderValidators.equalLength()` - requires the length of the field's value to be equal to the provided minimum length.
65
58
*`FormBuilderValidators.numeric()` - requires the field's value to be a valid number.
66
59
*`FormBuilderValidators.required()` - requires the field have a non-empty value.
67
-
*``FormBuilderValidators.url()`` - requires the field's value to be a valid url.
60
+
*`FormBuilderValidators.url()` - requires the field's value to be a valid url.
61
+
62
+
### Supported languages
63
+
64
+
Validators support default errorText messages in this languages:
65
+
66
+
- Arabic (ar)
67
+
- Bangla (bn)
68
+
- Catalan (ca)
69
+
- Chinese Simplified (zh_Hans)
70
+
- Chinese Traditional (zh_Hant)
71
+
- Czech (cs)
72
+
- English (en)
73
+
- Estonian (et)
74
+
- Dutch (nl)
75
+
- Farsi/Persian (fa)
76
+
- French (fr)
77
+
- German (de)
78
+
- Hungarian (hu)
79
+
- Indonesian (id)
80
+
- Italian (it)
81
+
- Japanese (ja)
82
+
- Korean (ko)
83
+
- Lao (lo)
84
+
- Polish (pl)
85
+
- Portuguese (pt)
86
+
- Romanian (ro)
87
+
- Russian (ru)
88
+
- Slovak (sk)
89
+
- Slovenian (sl)
90
+
- Spanish (es)
91
+
- Swahili (sw)
92
+
- Ukrainian (uk)
93
+
- Turkish (tr)
94
+
95
+
And you can still add your custom error messages.
96
+
97
+
## Use
98
+
99
+
### Setup
100
+
101
+
To allow for localization of default error messages within your app, add `FormBuilderLocalizations.delegate` in the list of your app's `localizationsDelegates`
102
+
103
+
```dart
104
+
return MaterialApp(
105
+
supportedLocales: [
106
+
Locale('de'),
107
+
Locale('en'),
108
+
Locale('es'),
109
+
Locale('fr'),
110
+
Locale('it'),
111
+
...
112
+
],
113
+
localizationsDelegates: [
114
+
GlobalMaterialLocalizations.delegate,
115
+
GlobalWidgetsLocalizations.delegate,
116
+
FormBuilderLocalizations.delegate,
117
+
],
118
+
```
119
+
120
+
### Basic use
121
+
122
+
```dart
123
+
TextFormField(
124
+
decoration: InputDecoration(labelText: 'Name'),
125
+
autovalidateMode: AutovalidateMode.always,
126
+
validator: FormBuilderValidators.required(),
127
+
),
128
+
```
129
+
130
+
See [pud.dev example tab](https://pub.dev/packages/form_builder_validators/example) or [github code](example/lib/main.dart) for more details
131
+
132
+
### Especific uses
133
+
134
+
#### Composing multiple validators
68
135
69
-
## Composing multiple validators
70
136
`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.
71
137
72
138
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.
@@ -99,89 +165,71 @@ TextFormField(
99
165
),
100
166
```
101
167
102
-
## l10n
103
-
To allow for localization of default error messages within your app, add `FormBuilderLocalizations.delegate` in the list of your app's `localizationsDelegates`
168
+
## Support
104
169
105
-
```dart
106
-
return MaterialApp(
107
-
supportedLocales: [
108
-
Locale('de'),
109
-
Locale('en'),
110
-
Locale('es'),
111
-
Locale('fr'),
112
-
Locale('it'),
113
-
...
114
-
],
115
-
localizationsDelegates: [
116
-
GlobalMaterialLocalizations.delegate,
117
-
GlobalWidgetsLocalizations.delegate,
118
-
FormBuilderLocalizations.delegate,
119
-
],
120
-
```
121
-
### Supported languages (default errorText messages)
122
-
- Arabic (ar)
123
-
- Bangla (bn)
124
-
- Catalan (ca)
125
-
- Chinese Simplified (zh_Hans)
126
-
- Chinese Traditional (zh_Hant)
127
-
- Czech (cs)
128
-
- English (en)
129
-
- Estonian (et)
130
-
- Dutch (nl)
131
-
- Farsi/Persian (fa)
132
-
- French (fr)
133
-
- German (de)
134
-
- Hungarian (hu)
135
-
- Indonesian (id)
136
-
- Italian (it)
137
-
- Japanese (ja)
138
-
- Korean (ko)
139
-
- Lao (lo)
140
-
- Polish (pl)
141
-
- Portuguese (pt)
142
-
- Romanian (ro)
143
-
- Russian (ru)
144
-
- Slovak (sk)
145
-
- Slovenian (sl)
146
-
- Spanish (es)
147
-
- Swahili (sw)
148
-
- Ukrainian (uk)
149
-
- Turkish (tr)
170
+
### Contribute
150
171
151
-
And you can still add your custom error messages.
172
+
You have some ways to contribute to this packages
152
173
153
-
## Support
154
-
### Issues and PRs
155
-
Any support in reporting bugs, answering questions, or PRs is always appreciated.
174
+
- Beginner: Reporting bugs or request new features
175
+
- Intermediate: Implement new features (from issues or not) and created pull requests
176
+
- Advanced: Join to [organization](#ecosystem) like a member and help coding, manage issues, dicuss new features and other things
177
+
178
+
See [contribution file](https://github.com/flutter-form-builder-ecosystem/.github/blob/main/CONTRIBUTING.md) for more details
179
+
180
+
#### Add new supported language
156
181
157
-
We especially welcome efforts to internationalize/localize the package by translating the default validation `errorText` strings for built-in validation rules.
182
+
We especially welcome efforts to internationalize/localize the package by translating the default validation `errorText` strings for built-in validation rules.
158
183
159
-
### Localizing messages
184
+
1. Add ARB files
160
185
161
-
#### 1. Add ARB files
162
186
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`.
163
187
164
-
#### 2. Translate the error messages
188
+
2. Translate the error messages
165
189
166
190
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.
167
191
168
-
#### 3. Run command
192
+
3. Generate localization code
193
+
169
194
To generate boilerplate code for localization, run the generate command inside the package directory where `pubspec.yaml` file is located:
170
195
171
-
```
172
-
flutter pub run intl_utils:generate
173
-
```
196
+
`flutter pub run intl_utils:generate`
174
197
175
198
Running the command will automatically create/update files inside the `lib/localization` directory, including your newly added locale support.
176
199
177
-
#### 4. Update README
178
-
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!
200
+
4. Update README
201
+
202
+
Remember to update README, adding the new language (and language code) under [Supported languages section](#supported-languages) so that everyone knows your new language is now supported!
203
+
204
+
5. Submit PR
179
205
180
-
#### 5. Submit PR
181
206
Submit your PR and be of help to millions of developers all over the world!
182
207
183
-
### Coffee :-)
184
-
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 ;-)
208
+
### Questions and answers
209
+
210
+
You can join to [our Discord server](https://discord.gg/25KNPMJQf2) or search answers in [StackOverflow](https://stackoverflow.com/questions/tagged/flutter-form-builder)
211
+
212
+
### Donations
213
+
214
+
Buy a coffe to [Danvick Miller](https://twitter.com/danvickmiller), creator of this awesome package
185
215
186
216
[](https://www.buymeacoffee.com/danvick)
187
217
218
+
## Roadmap
219
+
220
+
-[Solve open issues](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/issues), [prioritizing bugs](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/labels/bug)
221
+
222
+
223
+
## Ecosystem
224
+
225
+
Take a look to [our awesome ecosystem](https://github.com/flutter-form-builder-ecosystem) and all packages in there
0 commit comments