Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@zcorky/schema

zcorky20MIT1.0.11TypeScript support: included

Object schema validation written with TypeScript, inspired by dayjs and schema

zcorky, schema, joi, node, koa, typescript

readme

schema

NPM version NPM quality Coverage Status Dependencies Build Status Known Vulnerabilities NPM download license issues

Object schema description language and validator for JavaScript objects, inspired by hapijs/joi and hh54188/schemaor. It is written fully with Typescript.

  • 🕒 Familiar joi API & patterns
  • 💪 Node and Browser Support
  • 🔥 Chainable
  • :sparkle: TypeScript
  • 🌐 I18n support (WIP)
  • 🔌 Plugin System (WIP)

Install

$ npm install @zcorky/schema

Usage

import * as Types from '@zcorky/schema';

const user = new Types.object({
  id: new Types.string().require(),
  nickname: new Types.string().require(),
  homepage: new Types.string(),
  age: new Types.number(),
  active: new Types.boolean(),
});

const validatedData = Types.validate(user, {
  id: '1',
  nickname: 'whatwewant',
  active: true,
});

API

Relatived

  • joi - Object schema description language and validator for JavaScript objects..
  • schemaor
  • ajv -The fastest JSON Schema validator for Node.js and browser.

License

MIT © Moeover