Getting Started

Forward#

@zuze/schema was created out of love and admiration for projects like joi, yup, and ajv which are all schema validators. Each package brings it's own strengths. The strength (I hope) that @zuze/schema brings is that it's fun to use, whether you're somebody who likes to write functional code or somebody who likes to write highly reusable configuration (who doesn't love a some good YAML....but we use JSON.)

@zuze/schema is one package that comes in two flavors - functional or ast.

Throughout these docs code examples will be presented in tabs in functional and AST form (where applicable). Pick the one that's right for you and your project!

More on that after the set up:

Installation#

Install @zuze/schema using yarn or npm

npm install @zuze/schema

Creating a Schema#

Let's start by creating some very simple schemas:

import { ast } from '@zuze/schema'
const { matches } = ast;
matches({ schema: 'string', tests: [['min', 10]] }, 'short'); // false
matches({ schema: 'string', tests: [['min', 10]] }, 'this should work'); // true