singleErrorsBy<K> method

Map<K, String> singleErrorsBy<K>(
  1. Selector<E, K> tagSelector
)

Returns a map of formfield, error key value pairs.

The provided selector must be a the field in the provided error type that uniquely identifies the corresponding form field.

Implementation

Map<K, String> singleErrorsBy<K>(Selector<E, K> tagSelector) {
  return fold((errors) {
    final Map<K, String> map = {};

    for (final err in errors) {
      final tag = tagSelector(err);
      if (map[tag] == null) {
        map[tag] = err.errorDescription;
      } else {
        continue;
      }
    }
    return map;
  }, (_) => {});
}