noDependencyMatches static method

Validation<DartLibrary> noDependencyMatches(
  1. String regExp, {
  2. String? description,
})

Implementation

static Validation<DartLibrary> noDependencyMatches(
  String regExp, {
  String? description,
}) {
  return Validation(
    (lib, _, addViolation) {
      final regExpMatcher = RegExp(regExp);
      final invalidDependencies =
          lib.dependencies.where((dep) => regExpMatcher.hasMatch(dep.path));
      if (invalidDependencies.isNotEmpty) {
        addViolation(
          '${description ?? 'No dependency can match the regex "$regExp"'}.\n' +
              _buildInvalidImports(invalidDependencies),
        );
      }
    },
    description: 'not have dependencies matching the regex "$regExp"',
  );
}