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
Copy file name to clipboardExpand all lines: README-updated.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -169,7 +169,7 @@ Validators that check a generic type user input.
169
169
170
170
-`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.
171
171
-`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.
173
173
- TODO []`FormBuilderValidators.macAddress()` - requires the field's to be a valid MAC address.
Copy file name to clipboardExpand all lines: doc/migration.md
+60-3Lines changed: 60 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -902,12 +902,69 @@ Validators.and([
902
902
903
903
904
904
```
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
+
906
919
907
920
### Network validators
908
921
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
+
911
968
-`FormBuilderValidators.latitude()` - requires the field's to be a valid latitude.
912
969
-`FormBuilderValidators.longitude()` - requires the field's to be a valid longitude.
913
970
-`FormBuilderValidators.macAddress()` - requires the field's to be a valid MAC address.
0 commit comments