Plius for Node
⚠️ We are working hard on an alpha release. Below is what it will be able to do.
This is the JavaScript implementation of Plius, a language-agnostic document schema engine.
$ npm i --save plius
Plius uses generators to generate only the validation messages your application needs. This saves both in terms of logic to maintain and in performance.
Consider the following schema for validating a user:
userschema.json
Note that the above schema can be used with any other Plius engine.
console.log'Wrong fields:' for of violations console.logviolation.path
Results in the following output:
Wrong fields:
email
name
Which, using the translation engine, can be prettified to:
[{
path: "email"
, message: "Input did not match pattern."
}, {
path: "name",
, "message": "Minimum length of 5 characters required."
}]
API
new SchemaEngine(options)
- useDefault: whether to add the default constraints and types, such as String, Boolean and Float.