Closed 2shrestha22 closed 3 years ago
Yes of course.
ValidationBuilde()
.email()
.test('my@email.com')
I think it returns String
, isn't it?
I think it returns
String
, isn't it?
If the validation passed it will return null otherwise the error message will be returned. So you can check if value equals to null or not like that:
if (ValidationBuilde().email().test('my@email.com') == null) {
// validation passed
}
Or:
final result = ValidationBuilde().email().test('my@email.com');
if (result == null) {
// Validation passed
} else {
print('Validation error: $result');
}
Okay, thank you for the solution. Btw it will be a nice feature to add.
Is it possible to get bool also from validation result? I need to validate form in logic also not only in UI so if there is something like
ValidationBuilder().email().isValid('my@email.com')
is will be nice. Can this be achieved using extension?