# @expo/schemer

> Centralized scheme validation library for Expo

Latest version **2.3.0** (published 2026-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @expo/schemer
pnpm add @expo/schemer
yarn add @expo/schemer
bun add @expo/schemer
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2026-06-25 |
| First published | 2017-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 33.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52375 |
| Maintainers | ide, brentvatne, expoadmin, exponent, bycedric, kudochien, alanhughes, tsapeta, expo-bot, philpl, wschurman |

## Links

- npm: https://www.npmjs.com/package/@expo/schemer
- Repository: https://github.com/expo/expo
- Homepage: https://github.com/expo/expo/tree/main/packages/@expo/schemer#readme
- Issues: https://github.com/expo/expo/issues
- npm.io page: https://npm.io/package/@expo/schemer

## Dependencies (4)

- [ajv](https://npm.io/package/ajv.md) ^8.1.0
- [ajv-formats](https://npm.io/package/ajv-formats.md) ^2.0.2
- [probe-image-size](https://npm.io/package/probe-image-size.md) ^7.1.0
- [json-schema-traverse](https://npm.io/package/json-schema-traverse.md) ^1.0.0

## Recent versions

- 2.3.0 (latest) — 2026-06-25
- 2.4.0 (next) — 2026-09-10
- 3.0.0-canary-20260909-ea7a89a (canary) — 2026-09-09
- 2.2.2-canary-20260701-9100865 (canary-sdk-56) — 2026-07-01
- 2.1.5-canary-20260429-a5e59cf (canary-sdk-55) — 2026-04-29
- 1.5.2 (sdk-51) — 2024-04-23
- 1.5.0 (sdk-50) — 2023-12-12
- 1.3.27-alpha.0 (alpha) — 2021-02-18
- 3.0.0-canary-20260902-26df09e — 2026-09-02
- 3.0.0-canary-20260812-27f94d4 — 2026-08-12
- 3.0.0-canary-20260806-8c2d007 — 2026-08-06
- 3.0.0-canary-20260723-64edab9 — 2026-07-23
- 3.0.0-canary-20260720-b6d63bc — 2026-07-20
- 3.0.0-canary-20260718-7cbcda5 — 2026-07-18
- 3.0.0-canary-20260716-381e806 — 2026-07-16
- … 242 more at https://npm.io/package/@expo/schemer/versions

## README

<!-- Title -->
<h1 align="center">
👋 Welcome to <br><code>@expo/schemer</code>
</h1>

<p align="center">A Schema validation library for Expo.</p>

<!-- Body -->

Details can be found here:
* https://paper.dropbox.com/doc/Expo-Schema-Validation-Library-mQU07rRejSnEe4Vf5dkcS

## Usage

### Usage with XDL

```javascript
import { getConfig } from '@expo/config';
import Schemer from '@expo/schemer';

const { exp } = getConfig(projectRoot);
const schema = await getSchemaAsync(exp.sdkVersion);
const validator = new Schemer(require('schema.json'));

validator.validateName('Wilson Zhao');
validator.validateAssets(exp);
```

### Schema-only validation

```javascript
const validator = new Schemer(require('schema.json'));
try {
  await validator.validateSchemaAsync(require('data.json'));
} catch (e) {
  console.error(e);
}
```

### Validating a property

```javascript
const validator = new Schemer(require('schema.json'));
await validator.validateName('Wilson Zhao');
```

## Description

Schemer takes in a custom JSON Schema and uses it to validate various data.

Under the hood, it uses Ajv (https://github.com/epoberezkin/ajv) as the Javascript engine for basic schema validation.
However, each subschema also contains a custom meta tag, which can be parsed for further "manual" validation. As of now, Schemer supports manual validation for assets:

```javascript
{
  meta:
  {
    asset,
    contentType, //mime type
    dimensions: {width, height},
    square,

    // For custom error messages and docs
    regexHuman,
    autogenerated,
    notHuman
  }
}
```

All errors can be accessed in `this.errors`, which has a getter function that combines Ajv JSON Schema errors with custom meta/asset validation errors into a unified array of `ValidationErrors`.
If they exist, the errors are thrown at the end of each public-facing function.

All public-facing functions are async functions because asset validation has to be async (accessing the file-system or making a web request).

## API

#### new Schemer(Object JSON Schema, Object options) -> Object

#### .validateSchemaAsync(Object data) -> Promise

Returns a promise that resolve to `true` if the data is conforms to the schema. Otherwise, it rejects and throws an array of `ValidationError`s.

#### .validateAssetsAsync(Object data) -> Promise

Returns a promise that resolve to `true` if the data is conforms to the additional validation steps found in each meta tag. For example, it will download an asset and read the header of the file to see if it is a certain content type.
Otherwise, it rejects and throws an array of `ValidationError`s.

#### .validateAll(Object data) -> Promise

Runs both `.validateSchemaAsync` and `.validateAssetsAsync`.
Returns a promise that resolve to `true` if the data passes both functions. Otherwise, it rejects and throws an array of `ValidationError`s.

#### .validateProperty(String fieldPath, Object data) -> Promise

Extracts the subSchema for the given field path and validates the data against it. Also checks for the meta tag.
Returns a promise that resolve to `true` if the data conforms to the subschema. Otherwise, it rejects and throws an array of `ValidationError`s.

#### .errors

Contains an array of ValidationErrors

#### new ValidationError({errorCode, fieldPath, message, data, meta}) -> Object

---
_Source: https://npm.io/package/@expo/schemer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
