# `schemas`

The JSON Schema of each standard, for an editor, a form or another language.

## Example

```js [example.mjs]
// The JSON Schema of a document, and its problems against it (what an editor underlines).
import { schemaFields, schemaFor, validateSchema } from "@altasystem/sdk";

const schema = schemaFor("alta.quests/0.3");
console.log(schema.$id);
console.log(schemaFields(schema).length > 50);
console.log(validateSchema(schema, { schema: "alta.quests/0.3", id: "my-pack", branch: "core", quests: "none" }));
```

Run it from a folder where the package is installed: `node example.mjs`.

```text [Output]
alta.quests.schema.json
true
[ 'quests: must be array' ]
```

## Functions

### `schemaFor`

```ts
function schemaFor(schemaField: string): Schema | undefined
```

The schema of a document, by its `schema` field.

### `validateSchema`

```ts
function validateSchema(schema: Schema, value: unknown): string[]
```

Problems of a value against a schema (empty = valid): `<path>: <reason>`.

### `schemaFields`

```ts
function schemaFields(doc: Schema): SchemaField[]
```

Every field of a schema: the properties of its definitions and its root, each once (a shared node is walked once).

## See also

- [SDK](https://docs.altasystem.ai/reference/sdk/)
- [Errors](https://docs.altasystem.ai/reference/errors)
