perfect-schema v1.1.10
Perfect Schema
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
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago