# `schemas`

Le JSON Schema de chaque standard, pour un éditeur, un formulaire ou un autre langage.

*Les signatures et leurs descriptions sont en anglais, comme le code.*

## Exemple

```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" }));
```

Lance-le depuis un dossier où le paquet est installé : `node example.mjs`.

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

## Fonctions

### `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).

## Voir aussi

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