in lib/src/pattern_descriptor.dart [44:85]
Future<void> validate([String? parent]) async {
var inSandbox = parent == null;
parent ??= sandbox;
var matchingEntries = await Directory(parent)
.list()
.map((entry) =>
entry is File ? entry.resolveSymbolicLinksSync() : entry.path)
.where((entry) => matchesAll(pattern, p.basename(entry)))
.toList();
matchingEntries.sort();
var location = inSandbox ? 'sandbox' : '"${prettyPath(parent)}"';
if (matchingEntries.isEmpty) {
fail('No entries found in $location matching $_patternDescription.');
}
var results = await Future.wait(matchingEntries
.map((entry) {
var basename = p.basename(entry);
return runZonedGuarded(() {
return Result.capture(Future.sync(() async {
await _fn(basename).validate(parent);
return basename;
}));
}, (_, __) {
// Validate may produce multiple errors, but we ignore all but the first
// to avoid cluttering the user with many different errors from many
// different un-matched entries.
});
})
.whereType<Future<Result<String>>>()
.toList());
var successes = results.where((result) => result.isValue).toList();
if (successes.isEmpty) {
await waitAndReportErrors(results.map((result) => result.asFuture));
} else if (successes.length > 1) {
fail('Multiple valid entries found in $location matching '
'$_patternDescription:\n'
'${bullet(successes.map((result) => result.asValue!.value))}');
}
}