# core/matchers/lexicon.matcher.ts

> 13 lines of code and 2 definitions.

Tree: GovLab Context
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/context#file-context-core-matchers-lexicon-matcher-ts
Source text: https://banes-lab.com/source/context/core/matchers/lexicon.matcher.ts.txt

Listed in [core/matchers](https://banes-lab.com/api/source/context/core/matchers.md), after [core/matchers/filename.matcher.ts](https://banes-lab.com/source/context/core/matchers/filename.matcher.ts.md).

## Definitions

- `isWanted` (lexical_declaration, line 3)
- `matchesTerm` (lexical_declaration, line 7, exported)

## Contained in

- [core/matchers](https://banes-lab.com/anatomy/context/folder-context-core-matchers.md)

## Linked from

- [core/matchers](https://banes-lab.com/anatomy/context/folder-context-core-matchers.md)

## Source

```typescript
import type { Term, TermFilter } from "#types/lexicon.types";

const isWanted = function isWanted(value: string | undefined): value is string {
    return typeof value === "string" && value.length > 0;
};

export const matchesTerm = function matchesTerm(term: Term, filter: TermFilter): boolean {
    if (isWanted(filter.kind) && term.kind !== filter.kind) {
        return false;
    }
    if (isWanted(filter.category) && term.category !== filter.category) {
        return false;
    }
    return !isWanted(filter.enforcedBy) || term.enforcedBy.includes(filter.enforcedBy);
};
```
