-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Labels
featureA new feature or requestA new feature or requestp2Important issues not at the top of the work listImportant issues not at the top of the work list
Description
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
import 'package:formz/formz.dart';
import 'package:libphonenumber/libphonenumber.dart';
enum PhoneNumberValidationError { invalid }
class PhoneNumber extends FormzInput<String, PhoneNumberValidationError> {
const PhoneNumber.pure() : super.pure('');
const PhoneNumber.dirty([String value = '']) : super.dirty(value);
static final _phoneNumberRegex = RegExp(r'^[+]{1}[0-9]{1,4}[-\s\./0-9]*$');
@override
PhoneNumberValidationError validator(String value) {
return PhoneNumberUtil.isValidPhoneNumber(phoneNumber: "", isoCode: 'US').then((value){
return null;
});
}
}
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)
Toasbi, talamaska, arnemolland, jmsandiegoo, john-eevee and 12 more
Metadata
Metadata
Assignees
Labels
featureA new feature or requestA new feature or requestp2Important issues not at the top of the work listImportant issues not at the top of the work list
Type
Projects
Status
Backlog