# core/guards/context.guard.ts

> 32 lines of code and 6 definitions.

Tree: GovLab Context
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/context#file-context-core-guards-context-guard-ts
Source text: https://banes-lab.com/source/context/core/guards/context.guard.ts.txt

Listed in [core/guards](https://banes-lab.com/api/source/context/core/guards.md).

## Definitions

- `isArchRelations` (lexical_declaration, line 9, exported)
- `isAlgoGrammar` (lexical_declaration, line 13, exported)
- `isPagGrammar` (lexical_declaration, line 17, exported)
- `isLexicon` (lexical_declaration, line 21, exported)
- `isReasonOntology` (lexical_declaration, line 25, exported)
- `requireFace` (lexical_declaration, line 29, exported)

## Contained in

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

## Uses

- [configuration/strings/ontology.strings.ts](https://banes-lab.com/source/context/configuration/strings/ontology.strings.ts.md)
- [core/predicates/record.predicate.ts](https://banes-lab.com/source/context/core/predicates/record.predicate.ts.md)

## Linked from

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

## Source

```typescript
import type { AlgoGrammar } from "#types/algorithm.types";
import type { ArchRelations } from "#types/architecture.types";
import type { Lexicon } from "#types/lexicon.types";
import type { PagGrammar } from "#types/grammar.types";
import type { ReasonOntology } from "#types/reason.types";
import { isObject } from "#core/predicates/record.predicate";
import { unbuiltCollection } from "#configuration/strings/ontology.strings";

export const isArchRelations = function isArchRelations(value: unknown): value is ArchRelations {
    return isObject(value) && "resolve" in value && "validateOntology" in value;
};

export const isAlgoGrammar = function isAlgoGrammar(value: unknown): value is AlgoGrammar {
    return isObject(value) && "resolveClosure" in value;
};

export const isPagGrammar = function isPagGrammar(value: unknown): value is PagGrammar {
    return isObject(value) && "contextFor" in value;
};

export const isLexicon = function isLexicon(value: unknown): value is Lexicon {
    return isObject(value) && "resolve" in value && !("validateOntology" in value);
};

export const isReasonOntology = function isReasonOntology(value: unknown): value is ReasonOntology {
    return isObject(value) && "derivationLoop" in value;
};

export const requireFace = function requireFace<T>(
    value: unknown,
    guard: (candidate: unknown) => candidate is T,
    name: string,
): T {
    if (!guard(value)) {
        throw new Error(unbuiltCollection(name));
    }
    return value;
};
```
