test method
Tests value
against defined validations
Implementation
String? test(String? value) {
for (var validate in validations) {
// Return null if field is optional and value is null
if (optional && (value == null || value.isEmpty)) {
return null;
}
// Otherwise execute validations
final result = validate(value);
if (result != null) {
return result;
}
}
return null;
}