errorsGroupedBy<K> method
Returns a map of grouped validation errors keyed by a formfield type.
The provided selector must be a the field in the provided error that uniquely identifies the corresponding form field.
Implementation
Map<K, List<E>> errorsGroupedBy<K>(Selector<E, K> tagSelector) {
return fold((errors) {
final Map<K, List<E>> map = {};
for (final err in errors) {
final tag = tagSelector(err);
final list = map[tag];
list?.add(err);
map[tag] = list ?? [err];
}
return map;
}, (_) => {});
}