0.0.3 • Published 2 years ago

simple-shape v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

simple-shape

A simple function for building JSON Schema.

Basic Usage


import Ajv from "ajv"
import { shape } from 'simple-shape'

const ajv = new Ajv()

const Message = shape({
  id: Number,
  type: anyOf('short', 'long'),
  text: String,
})

// TypeOf<typeof Message> -> { id: number, type: 'short' | 'long', text: string }

const message = {
    id: 1,
    type: 'short',
    text: 'Hello, world!',
}

ajv.validate(shape, message);
0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago