-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A validator of type Future #15
Comments
Not entirely sure if this falls into the same use case, but I think this would be great too for scenarios involving asynchronous validation of fields. |
+1 |
2 similar comments
+1 |
+1 |
@felangel any update on this? It seems to me the simplest solution would necessitate rewriting Formz to include async validation functions. |
I'd propose changing the return type to Previously@override
PhoneNumberValidationError validator(String value) {
return PhoneNumberUtil.isValidPhoneNumber(phoneNumber: "", isoCode: 'US').then((value){
return null;
});
} After@override
FutureOr<PhoneNumberValidationError> validator(String value) async {
return PhoneNumberUtil.isValidPhoneNumber(phoneNumber: "", isoCode: 'US');
} And add |
+1 ! Are there any workarounds to do async validations? |
Looking at the PR discussion, it seems like there will be no async validation in the future. This is a deal breaker. In most real production application, there must be a use case for async valdiation. |
@Firman95 we are open to work on async validation for Formz. I'm aware that this is a valuable feature for production applications. We want to make sure that when doing so users that will only rely on synchronous validation are not hindered. If you want this to happen drop a 👍 on the issue, stay tuned! |
@alestiago Hello, any update on this? |
Hi @MiniSuperDev not so far. We haven't committed to this work yet (it's a P2), but since it has a decent number of 👍 , I'm moving it to triage so we can re-prioritise this. |
Hello,
I'm trying to use Formz to validate a phonenumber using the https://pub.dev/packages/libphonenumber library.
But libphonenumber's validation function returns a Future, so I was unable to use it in the validator() function of Formz
error: A value of type 'Future<Null>' can't be returned from method 'validator' because it has a return type of 'PhoneNumberValidationError'. (return_of_invalid_type at [datoraid] lib/models/phone_number.dart:16)
The text was updated successfully, but these errors were encountered: