Skip to content

Commit db85c06

Browse files
add some migrations
1 parent 5536724 commit db85c06

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

README-updated.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Validators that check a generic type user input.
169169

170170
- `Validators.ip()`: Checks if the field contains a properly formatted `Internet Protocol` (IP) address. It may check for either `IPv4`, or `IPv6` or even for both.
171171
- `Validators.url()`: Checks if the field contains a properly formatted `Uniform Resource Locators` (URL).
172-
- TODO [ ] `FormBuilderValidators.email()` - requires the field's value to be a valid email address.
172+
- `FormBuilderValidators.email()`: Checks if the field contains a valid email.
173173
- TODO [ ] `FormBuilderValidators.macAddress()` - requires the field's to be a valid MAC address.
174174

175175
### Numeric validators

doc/migration.md

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,12 +902,69 @@ Validators.and([
902902
903903
904904
```
905-
- `FormBuilderValidators.zipCode()` - requires the field's to be a valid zip code.
905+
- `FormBuilderValidators.zipCode()`: there is no equivalent to [this validator](https://github.com/flutter-form-builder-ecosystem/form_builder_validators/blob/17e982bb849dc68365f8fbc93d5a2323ee891c89/lib/src/identity/zip_code_validator.dart#L43). Something close would be:
906+
```dart
907+
// Old API:
908+
FormBuilderValidators.zipCode(
909+
errorText: 'error text',
910+
);
911+
912+
// New API:
913+
Validators.match(
914+
RegExp(r'^\d{5}(?:[-\s]\d{4})?$'),
915+
matchMsg: (_)=>'error text'
916+
);
917+
```
918+
906919

907920
### Network validators
908921

909-
- `FormBuilderValidators.email()` - requires the field's value to be a valid email address.
910-
- `FormBuilderValidators.ip()` - requires the field's value to be a valid IP address.
922+
- `FormBuilderValidators.email()`
923+
```dart
924+
// Old API:
925+
FormBuilderValidators.email(
926+
regex: emailRegex,
927+
errorText: 'invalid email',
928+
);
929+
930+
// New API:
931+
Validators.email(
932+
regex: emailRegex,
933+
emailMsg: (_)=>'invalid email',
934+
);
935+
```
936+
937+
- `FormBuilderValidators.ip()`
938+
```dart
939+
// For IPv4
940+
// Old API:
941+
FormBuilderValidators.ip(
942+
regex: ipRegex,
943+
errorText: 'invalid ipV4',
944+
);
945+
946+
// New API:
947+
Validators.ip(
948+
regex: ipRegex,
949+
emailMsg: (_)=>'invalid ipV4',
950+
);
951+
952+
// For IPv6
953+
// Old API:
954+
FormBuilderValidators.ip(
955+
version: 6
956+
regex: ipRegex,
957+
errorText: 'invalid ipV4',
958+
);
959+
960+
// New API:
961+
Validators.ip(
962+
version: IpVersion.iPv6,
963+
regex: ipRegex,
964+
emailMsg: (_)=>'invalid ipV4',
965+
);
966+
```
967+
911968
- `FormBuilderValidators.latitude()` - requires the field's to be a valid latitude.
912969
- `FormBuilderValidators.longitude()` - requires the field's to be a valid longitude.
913970
- `FormBuilderValidators.macAddress()` - requires the field's to be a valid MAC address.

0 commit comments

Comments
 (0)