validate method

void validate({
  1. required EagleEyeConfig config,
  2. required Iterable<String> filePaths,
})

Validates config against the given filePaths.

Throws an InvalidConfigException when the configuration is structurally invalid or when a file matches more than one rule.

Implementation

void validate({
  required EagleEyeConfig config,
  required Iterable<String> filePaths,
}) {
  final structureProblems = _validateStructure(config);
  if (structureProblems.isNotEmpty) {
    throw InvalidConfigException(structureProblems.join('\n'));
  }

  final files = filePaths.toList();
  onCheck?.call(
    'Validating ${config.items.length} rule(s) against '
    '${files.length} file(s)',
  );

  final conflicts = _findConflicts(config, files);
  if (conflicts.isNotEmpty) {
    throw InvalidConfigException(_conflictMessage(config, conflicts));
  }
}