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