# tools/core/predicates/schema.predicate.ts

> 46 lines of code and 4 definitions.

Tree: Coordination tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-predicates-schema-predicate-ts
Source text: https://banes-lab.com/assets/sources/source.a275de4b41db48c249b54d4e6be52a754517e58f3929ef3608eeb8cd28b7279a.generated.txt

## Definitions

- `isObject` (lexical_declaration, line 3, exported)
- `hasFields` (lexical_declaration, line 19, exported)
- `isCorpusMoveList` (lexical_declaration, line 34, exported)
- `isStringMap` (lexical_declaration, line 7, exported)

## Used by

- [tools/core/entrypoints/corpus.entrypoint.ts](https://banes-lab.com/source/coordination/tools/core/entrypoints/corpus.entrypoint.ts.md)
- [tools/core/inspectors/manifest.inspector.ts](https://banes-lab.com/source/coordination/tools/core/inspectors/manifest.inspector.ts.md)
- [tools/core/readers/source.reader.ts](https://banes-lab.com/source/coordination/tools/core/readers/source.reader.ts.md)
- [tools/core/runners/gate.runner.ts](https://banes-lab.com/source/coordination/tools/core/runners/gate.runner.ts.md)
- [tools/core/validators/governance.validator.ts](https://banes-lab.com/source/coordination/tools/core/validators/governance.validator.ts.md)

## Source

```typescript
import type { CorpusMove } from "../types/corpus.types.ts";

export const isObject = function isObject(value: unknown): value is Record<string, unknown> {
    return typeof value === "object" && value !== null && !Array.isArray(value);
};

export const isStringMap = function isStringMap(value: unknown): value is Record<string, string> {
    if (!isObject(value)) {
        return false;
    }
    for (const item of Object.values(value)) {
        if (typeof item !== "string") {
            return false;
        }
    }
    return true;
};

export const hasFields = function hasFields(
    value: unknown,
    fields: readonly string[],
): value is Record<string, unknown> {
    if (!isObject(value)) {
        return false;
    }
    for (const field of fields) {
        if (!(field in value)) {
            return false;
        }
    }
    return true;
};

export const isCorpusMoveList = function isCorpusMoveList(value: unknown): value is CorpusMove[] {
    if (!Array.isArray(value)) {
        return false;
    }
    for (const item of value) {
        if (!hasFields(item, ["from", "to", "facet", "key", "variant"])) {
            return false;
        }
        if (typeof item["from"] !== "string" || typeof item["to"] !== "string") {
            return false;
        }
        if (typeof item["facet"] !== "string" || typeof item["key"] !== "string") {
            return false;
        }
    }
    return true;
};
```
