Skip to content

Commit 3a0c02a

Browse files
author
Martin Edlman
committed
Merge branch 'main' of github.com:flutter-form-builder-ecosystem/form_builder_validators
Signed-off-by: Martin Edlman <[email protected]> # Conflicts: # CHANGELOG.md # README.md # example/pubspec.lock # pubspec.yaml
2 parents 27884df + f7cac9e commit 3a0c02a

16 files changed

+315
-772
lines changed

.github/workflows/base.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,13 @@ jobs:
7878
sh ./tool/pub_login.sh
7979
- name: Publish package
8080
run: dart pub publish -v -f
81+
- name: Build changelog
82+
id: github_release
83+
uses: mikepenz/release-changelog-builder-action@v3
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
- name: Create release
87+
uses: softprops/[email protected]
88+
with:
89+
body: ${{steps.github_release.outputs.changelog}}
90+

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [8.3.0] - 28-Jul-2022
2+
3+
* Apply license BSD-3-clause
4+
* Refactor readme
5+
* Remove unused dependency
6+
* Add web example
7+
18
## [8.2.1] - 20-Jul-2022
29

310
* Added Czech language support

LICENSE

Lines changed: 6 additions & 669 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 145 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,44 @@
11
# Form Builder Validators
22

3-
Form Builder Validators set of validators for FlutterFormBuilder. Provides common validators and a way to make your own.
3+
Form Builder Validators set of validators for `FlutterFormBuilder`. Provides common validators and a way to make your own.
44

55
Also included is the `l10n` / `i18n` of error text messages to multiple languages.
6-
___
76

87
[![Pub Version](https://img.shields.io/pub/v/form_builder_validators?logo=flutter&style=for-the-badge)](https://pub.dev/packages/form_builder_validators)
98
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/flutter-form-builder-ecosystem/form_builder_validators/Base?logo=github&style=for-the-badge)](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/actions/workflows/base.yaml)
109
[![Codecov](https://img.shields.io/codecov/c/github/flutter-form-builder-ecosystem/form_builder_validators?logo=codecov&style=for-the-badge)](https://codecov.io/gh/flutter-form-builder-ecosystem/form_builder_validators/)
1110
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/flutter-form-builder-ecosystem/form_builder_validators?logo=codefactor&style=for-the-badge)](https://www.codefactor.io/repository/github/flutter-form-builder-ecosystem/form_builder_validators)
11+
[![Discord](https://img.shields.io/discord/985922433578053673?logo=discord&style=for-the-badge)](https://discord.com/invite/25KNPMJQf2)
1212

13-
14-
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-1.svg)](https://www.buymeacoffee.com/danvick)
1513
___
1614

1715
> ### Migrating from version 7 to 8
1816
> 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.
1917
20-
### Example
21-
```dart
22-
import 'package:form_builder_validators/form_builder_validators.dart';
18+
- [Features](#features)
19+
- [Validators](#validators)
20+
- [Supported languages](#supported-languages)
21+
- [Use](#use)
22+
- [Setup](#setup)
23+
- [Basic use](#basic-use)
24+
- [Especific uses](#especific-uses)
25+
- [Support](#support)
26+
- [Contribute](#contribute)
27+
- [Questions and answers](#questions-and-answers)
28+
- [Donations](#donations)
29+
- [Roadmap](#roadmap)
30+
- [Ecosystem](#ecosystem)
31+
- [Thanks to](#thanks-to)
32+
- [Contributors](#contributors)
2333

24-
...
2534

26-
TextFormField(
27-
decoration: InputDecoration(labelText: 'Name'),
28-
autovalidateMode: AutovalidateMode.always,
29-
validator: FormBuilderValidators.required(),
30-
),
31-
TextFormField(
32-
decoration: InputDecoration(labelText: 'Age'),
33-
keyboardType: TextInputType.number,
34-
autovalidateMode: AutovalidateMode.always,
35-
validator: FormBuilderValidators.compose([
36-
FormBuilderValidators.numeric(errorText: 'La edad debe ser numérica.'),
37-
FormBuilderValidators.max(70),
38-
(val) {
39-
var number = int.tryParse(val ?? '');
40-
if (number != null) if (number < 0)
41-
return 'We cannot have a negative age';
42-
return null;
43-
}
44-
]),
45-
),
46-
```
35+
## Features
36+
37+
- Multiple form inputs validators
38+
- Automatic error messages in several languages
39+
40+
## Validators
4741

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

@@ -61,12 +54,85 @@ Available built-in validators include:
6154
* `FormBuilderValidators.maxLength()` - requires the length of the field's value to be less than or equal to the provided maximum length.
6255
* `FormBuilderValidators.min()` - requires the field's value to be greater than or equal to the provided number.
6356
* `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.
6558
* `FormBuilderValidators.numeric()` - requires the field's value to be a valid number.
6659
* `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
68135

69-
## Composing multiple validators
70136
`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.
71137

72138
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(
99165
),
100166
```
101167

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
104169

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
150171

151-
And you can still add your custom error messages.
172+
You have some ways to contribute to this packages
152173

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
156181

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.
158183

159-
### Localizing messages
184+
1. Add ARB files
160185

161-
#### 1. Add ARB files
162186
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`.
163187

164-
#### 2. Translate the error messages
188+
2. Translate the error messages
165189

166190
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.
167191

168-
#### 3. Run command
192+
3. Generate localization code
193+
169194
To generate boilerplate code for localization, run the generate command inside the package directory where `pubspec.yaml` file is located:
170195

171-
```
172-
flutter pub run intl_utils:generate
173-
```
196+
`flutter pub run intl_utils:generate`
174197

175198
Running the command will automatically create/update files inside the `lib/localization` directory, including your newly added locale support.
176199

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
179205

180-
#### 5. Submit PR
181206
Submit your PR and be of help to millions of developers all over the world!
182207

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
185215

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

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
226+
227+
## Thanks to
228+
229+
### Contributors
230+
231+
<a href="https://github.com/flutter-form-builder-ecosystem/form_builder_validators/graphs/contributors">
232+
<img src="https://contrib.rocks/image?repo=flutter-form-builder-ecosystem/form_builder_validators" />
233+
</a>
234+
235+
Made with [contrib.rocks](https://contrib.rocks).

example/.metadata

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled and should not be manually edited.
4+
# This file should be version controlled.
55

66
version:
7-
revision: adc687823a831bbebe28bdccfac1a628ca621513
7+
revision: 85684f9300908116a78138ea4c6036c35c9a1236
88
channel: stable
99

1010
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 85684f9300908116a78138ea4c6036c35c9a1236
17+
base_revision: 85684f9300908116a78138ea4c6036c35c9a1236
18+
- platform: web
19+
create_revision: 85684f9300908116a78138ea4c6036c35c9a1236
20+
base_revision: 85684f9300908116a78138ea4c6036c35c9a1236
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ packages:
7878
path: ".."
7979
relative: true
8080
source: path
81-
version: "8.2.1"
81+
version: "8.3.0"
8282
intl:
8383
dependency: transitive
8484
description:

example/web/favicon.png

917 Bytes
Loading

example/web/icons/Icon-192.png

5.17 KB
Loading

example/web/icons/Icon-512.png

8.06 KB
Loading

0 commit comments

Comments
 (0)