firstError<ErrorType> method
ErrorType?
firstError<ErrorType>(
- S subject
Runs the validator and returns the first error of the provided generic type
When supplied a type parameter the error list will be filtered to all errors that have the given type. This is handy when just error information is required.
Implementation
ErrorType? firstError<ErrorType>(S subject) {
return this(subject).leftMap((errors) {
final Iterable<ErrorType> filtered = errors.whereType();
final list = filtered.toList();
return list.isEmpty ? null : list.first;
}).fold((l) => l, (r) => null);
}