allows method

bool allows(
  1. Map<String, Object?> raw,
  2. String path
)

Implementation

bool allows(Map<String, Object?> raw, String path) {
  final rawTags = raw['tags'];
  final documentTags = rawTags is List
      ? rawTags.whereType<String>().toSet()
      : <String>{};
  // OKF defines the absent lifecycle status as stable. Keep producer-defined
  // values intact rather than collapsing all custom values to `unknown`.
  final status = raw.containsKey('status') ? raw['status'] : 'stable';
  bool contains(Object? value, String? query) =>
      query == null ||
      (value is String && value.toLowerCase().contains(query.toLowerCase()));
  return (tags.isEmpty || tags.any(documentTags.contains)) &&
      requiredTags.every(documentTags.contains) &&
      (types.isEmpty || types.contains(raw['type'])) &&
      (statuses.isEmpty || statuses.contains(status)) &&
      (pathPrefixes.isEmpty ||
          pathPrefixes.any(OkfConceptId.fromDocumentPath(path).isWithin)) &&
      contains(raw['title'], titleContains) &&
      contains(raw['description'], descriptionContains);
}