This package has been deprecated

Author message:

Deprecated package, please install @perfect-schema/base from now on

perfect-schema

1.1.10 • Public • Published

Perfect Schema

Build Status Coverage Status

NPM

Model and schema validation done perfectly.

Install

npm i -S perfect-schema

Requirements

This modules does not provide a polyfill for a global Promise impelementation if none is available. If such is the case, an ECMA-262 complient implementation should be defined before declaring any schema.

A client version of this module can be built using Gulp (i.e. $ gulp) which can then be found in the dist folder. If installed through npm, this file should already be provided as dist/perfect-schema.min.js. The client module is wrapped by a UMD, and also globally exposes a PerfectSchema constructor.

Usage

const PerfectSchema = require('perfect-schema');
 
const itemSchema = new PerfectSchema({
  _id: String,
  name: {
    type: String,
    required: true,
    min: 3
  },
  qty: {
    type: PerfectSchema.Integer,
    defaultValue: 0
  },
  price: Number,
  tags: [String],
  attributes: Object
});
 
const item = itemSchema.createModel();  // all default values set
 
const messages = await item.set({
  name: 'foo'
});
 
if (!item.isValid()) {
  console.error(messages);
}

Documentation

Read the documentation for more information.

license

ISC

Readme

Keywords

Package Sidebar

Install

npm i perfect-schema

Weekly Downloads

1

Version

1.1.10

License

ISC

Last publish

Collaborators

  • yanickrochon