1.1.10 • Published 7 years ago

perfect-schema v1.1.10

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

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

1.1.10

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.4

7 years ago

1.1.2

7 years ago

1.1.0

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.14

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.8

7 years ago

1.0.6

7 years ago

1.0.2

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.2

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.2

7 years ago