Skip to content

Commit a10cb0b

Browse files
committed
Merge remote-tracking branch 'repo/main'
2 parents c25ef36 + 88cad03 commit a10cb0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3521
-3018
lines changed

.github/dependabot.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
enable-beta-ecosystems: true
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
- package-ecosystem: "pub"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/workflows/base.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install dependencies
3636
run: flutter pub get
3737
- name: Format code
38-
run: flutter format --dry-run --set-exit-if-changed .
38+
run: flutter format --dry-run --set-exit-if-changed $(find . -name "*.dart" -not -wholename "./lib/localization/intl/*")
3939
- name: Analyze static code
4040
run: flutter analyze
4141
- name: Run tests

.github/workflows/stale.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Close stale issues"
2+
on:
3+
schedule:
4+
- cron: "30 1 * * *"
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v7
11+
with:
12+
repo-token: ${{ secrets.GITHUB_TOKEN }}
13+
stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days."
14+
close-issue-message: "This issue was closed because it has been stalled for 7 days with no activity."
15+
days-before-stale: 30
16+
days-before-pr-close: -1
17+
any-of-issue-labels: 'awaiting author response'

CHANGELOG.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,114 @@
1-
## [8.3.0] - 28-Jul-2022
1+
## 8.4.0
2+
3+
* Refactor l10n generator. Thanks [@ipcjs]()
4+
* Add property to allow empty on equalLength validator. Thanks [@CircleCurve](https://github.com/CircleCurve)
5+
* Add support for more languanges
6+
- Czech. Thanks [@edlman](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/pull/3)
7+
- Bosnian and Croatian. Thanks [@abratanovic](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/pull/9)
8+
- Malay. Thanks [@azmilazizi](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/pull/13)
9+
- Thai. Thanks [@narospol](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/pull/19)
10+
- Tamil. Thanks [@Purus](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/pull/26)
11+
- Greek. Thanks [@nrallakis](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/pull/27)
12+
13+
## 8.3.0
214

315
* Apply license BSD-3-clause
416
* Refactor readme
517
* Remove unused dependency
618
* Add web example
719

8-
## [8.2.1] - 20-Jul-2022
20+
## 8.2.1
921

1022
* Added Czech language support
1123

12-
## [8.2.0] - 12-Jul-2022
24+
## 8.2.0
1325

1426
* Added equalLength validator
1527
* Added turkish language support
1628
* Moved repository
1729

18-
## [8.1.1] - 26-Apr-2022
30+
## 8.1.1
1931

2032
* Fixed issue where email validator trims string before validation
2133

22-
## [8.1.0] - 13-Apr-2022
34+
## 8.1.0
2335

2436
* Added Romanian (ro) language support
2537

26-
## [8.0.0] - 10-Apr-2022
38+
## 8.0.0
2739

2840
* **BREAKING CHANGE**: Avoid passing context to validator functions.
2941
* Added Swahili (sw) language support
3042

31-
## [7.9.0] - 04-Apr-2022
43+
## 7.9.0
3244

3345
* Added Bangla (bn) language support
3446

35-
## [7.8.0] - 29-Mar-2022
47+
## 7.8.0
3648

3749
* Added Estonian (et) language support
3850
* Improved and corrected Arabic translations
3951

40-
## [7.7.0] - 15-Mar-2022
52+
## 7.7.0
4153

4254
* Added Catalan (ca) language support
4355

44-
## [7.6.1] - 19-Feb-2022
56+
## 7.6.1
4557

4658
* Fixed duplicate `en` locale translations. Fixes #969
4759

48-
## [7.6.0] - 18-Feb-2022
60+
## 7.6.0
4961

5062
* Added Ukrainian (uk) language support
5163

52-
## [7.5.0] - 17-Feb-2022
64+
## 7.5.0
5365

5466
* Added Lao (lo) language support
5567
* Added Dutch (nl) language support
5668

57-
## [7.4.0] - 31-Jan-2022
69+
## 7.4.0
5870

5971
* Added Russian (ru) language support
6072

61-
## [7.3.0] - 10-Jan-2022
73+
## 7.3.0
6274

6375
* Added support for Slovenian (sl)
6476
* Added Chinese language support - both traditional (zh_Hant) and simplified (zh_Hans)
6577

66-
## [7.2.0] - 06-Nov-2021
78+
## 7.2.0
6779

6880
* Added language support for Indonesian (id)
6981

70-
## [7.1.0] - 06-Nov-2021
82+
## 7.1.0
7183

7284
* Added language support for Korean (ko)
7385

74-
## [7.0.0] - 02-Sep-2021
86+
## 7.0.0
7587

76-
* New Package 🎉🎊 - Split from and no dependency on [flutter_form_builder](https://pub.dev/packages/flutter_form_builder)
88+
* New Package 🎉🎊 - Split from and no dependency on flutter_form_builder(https://pub.dev/packages/flutter_form_builder)
7789
* Added Arabic and Persian/Farsi support
7890
* Use `intl_utils` package for localization
7991
* Minor type fixes
8092
* Documentation and example improvements
8193

82-
## [7.0.0-RC.1] - 02-Sep-2021
94+
## 7.0.0-RC.1
8395

8496
* `maxLength` and `minLength` validators can now work with `Iterable` field values length
8597

86-
## [7.0.0-RC.0] - 01-Sep-2021
98+
## 7.0.0-RC.0
8799

88100
* Added Arabic and Persian/Farsi support
89101

90-
## [7.0.0-beta.0] - 19-May-2021
102+
## 7.0.0-beta.0
91103

92104
* Use `intl_utils` package for localization
93105
* Documentation and example improvements - added instructions for localization
94106
* Minor type fixes
95107

96-
## [7.0.0-alpha.2] - 17-May-2021
108+
## 7.0.0-alpha.2
97109

98110
* Improvements to package documentation and example
99111

100-
## [7.0.0-alpha.1] - 16-May-2021
112+
## 7.0.0-alpha.1
101113

102114
* Split into own package from `flutter_form_builder`

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Validators support default errorText messages in this languages:
7979
- Dutch (nl)
8080
- Farsi/Persian (fa)
8181
- French (fr)
82+
- Greek (el)
8283
- German (de)
8384
- Hungarian (hu)
8485
- Indonesian (id)
@@ -95,6 +96,8 @@ Validators support default errorText messages in this languages:
9596
- Spanish (es)
9697
- Swahili (sw)
9798
- Ukrainian (uk)
99+
- Tamil(ta)
100+
- Thai (th)
98101
- Turkish (tr)
99102
- Malay (ms)
100103

@@ -104,7 +107,7 @@ And you can still add your custom error messages.
104107

105108
### Setup
106109

107-
To allow for localization of default error messages within your app, add `FormBuilderLocalizations.delegate` in the list of your app's `localizationsDelegates`
110+
The default error message is in English. To allow for localization of default error messages within your app, add `FormBuilderLocalizations.delegate` in the list of your app's `localizationsDelegates`
108111

109112
```dart
110113
return MaterialApp(
@@ -172,6 +175,10 @@ TextFormField(
172175
),
173176
```
174177

178+
#### Modify the default error message in a specific language
179+
180+
see [override_form_builder_localizations_en](example/lib/override_form_builder_localizations_en.dart) for more detail.
181+
175182
## Support
176183

177184
### Contribute
@@ -194,13 +201,13 @@ Create one ARB file inside the `lib/l10n` folder for each of the locales you nee
194201

195202
2. Translate the error messages
196203

197-
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.
204+
Duplicate the contents of `intl_en.arb` (or any other ARB file) into your newly created ARB file, then translate the error messages by overwriting the default messages.
198205

199206
3. Generate localization code
200207

201208
To generate boilerplate code for localization, run the generate command inside the package directory where `pubspec.yaml` file is located:
202209

203-
`flutter pub run intl_utils:generate`
210+
`flutter gen-l10n`
204211

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

example/lib/home_page.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:form_builder_validators/form_builder_validators.dart';
33

44
class HomePage extends StatefulWidget {
5-
const HomePage({Key key}) : super(key: key);
5+
const HomePage({Key? key}) : super(key: key);
66

77
@override
88
HomePageState createState() => HomePageState();
@@ -42,9 +42,11 @@ class HomePageState extends State<HomePage> {
4242
/// Include your own custom `FormFieldValidator` function, if you want
4343
/// Ensures positive values only. We could also have used `FormBuilderValidators.min( 0)` instead
4444
(val) {
45-
final number = int.tryParse(val);
46-
if (number == null) return null;
47-
if (number < 0) return 'We cannot have a negative age';
45+
if (val != null) {
46+
final number = int.tryParse(val);
47+
if (number == null) return null;
48+
if (number < 0) return 'We cannot have a negative age';
49+
}
4850
return null;
4951
}
5052
]),

example/lib/main.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:example/override_form_builder_localizations_en.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flutter_localizations/flutter_localizations.dart';
34
import 'package:form_builder_validators/form_builder_validators.dart';
@@ -9,17 +10,21 @@ void main() {
910
}
1011

1112
class MyApp extends StatelessWidget {
12-
const MyApp({Key key}) : super(key: key);
13+
const MyApp({Key? key}) : super(key: key);
1314

1415
@override
1516
Widget build(BuildContext context) {
1617
return MaterialApp(
1718
title: 'Form Builder Validators Demo',
1819
theme: ThemeData(primarySwatch: Colors.blue),
1920
home: const HomePage(),
20-
supportedLocales: [...FormBuilderLocalizations.delegate.supportedLocales],
21+
supportedLocales: const [
22+
...FormBuilderLocalizations.supportedLocales,
23+
],
2124
localizationsDelegates: const [
2225
...GlobalMaterialLocalizations.delegates,
26+
// Placed in front of `FormBuilderLocalizations.delegate`
27+
OverrideFormBuilderLocalizationsEn.delegate,
2328
FormBuilderLocalizations.delegate,
2429
],
2530
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'package:flutter/foundation.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:form_builder_validators/form_builder_validators.dart';
4+
5+
/// Created by ipcjs on 2022/10/31.
6+
class OverrideFormBuilderLocalizationsEn
7+
extends FormBuilderLocalizationsImplEn {
8+
OverrideFormBuilderLocalizationsEn();
9+
10+
static const LocalizationsDelegate<FormBuilderLocalizationsImpl> delegate =
11+
_LocalizationsDelegate();
12+
13+
static const List<Locale> supportedLocales = [Locale('en')];
14+
15+
// Override a field and return your translation.
16+
@override
17+
String get requiredErrorText => 'override: This field cannot be empty.';
18+
}
19+
20+
class _LocalizationsDelegate
21+
extends LocalizationsDelegate<FormBuilderLocalizationsImpl> {
22+
const _LocalizationsDelegate();
23+
24+
@override
25+
Future<FormBuilderLocalizationsImpl> load(Locale locale) {
26+
final instance = OverrideFormBuilderLocalizationsEn();
27+
// IMPORTANT!! must to invoke setCurrentInstance()
28+
FormBuilderLocalizations.setCurrentInstance(instance);
29+
return SynchronousFuture<FormBuilderLocalizationsImpl>(instance);
30+
}
31+
32+
@override
33+
bool isSupported(Locale locale) =>
34+
OverrideFormBuilderLocalizationsEn.supportedLocales.contains(locale);
35+
36+
@override
37+
bool shouldReload(_LocalizationsDelegate old) => false;
38+
}

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ packages:
7171
path: ".."
7272
relative: true
7373
source: path
74-
version: "8.3.0"
74+
version: "8.4.0"
7575
intl:
7676
dependency: transitive
7777
description:

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
44
version: 1.0.0+1
55

66
environment:
7-
sdk: ">=2.7.0 <3.0.0"
7+
sdk: ">=2.12.0 <3.0.0"
88
flutter: ">=3.0.0"
99

1010
dependencies:

0 commit comments

Comments
 (0)