validate method

  1. @override
Future<void> validate()
override

Invoke validation across all connected ValidationConnector

Implementation

@override
Future<void> validate() {
  return Future.wait(
          _connectors.map<Future<_ValidationResult<K>>>((connector) {
    return Future.microtask(
        () => _ValidationResult<K>(connector.field, connector.validate()));
  }).toList())
      .then((collection) {
    return collection.fold<Map<K, String>>({}, (value, result) {
      if (!result.hasError) {
        return value;
      }

      return {
        ...value,
        result.field: result.error!,
      };
    });
  }).then(addErrors);
}