seneca-parambulator
v0.3.0
Published
Seneca plugin that provides parambulator message validation.
Downloads
120
Readme
A Seneca.js plugin that validates messages using the parambulator module.
seneca-parambulator
This plugin is included by default in Seneca 2.x.
NOTE: This plugin will not be included by default in Seneca 3.x and above, and will need to be installed manually.
Seneca compatibility
Supports Seneca versions 1.x - 3.x
Installation
This is needed only for Seneca 3.x and above.
npm install seneca-parambulator
And in your code:
require('seneca')()
.use('parambulator')
Usage
You can validate action messages by providing parambulator rules as part of the action definition.
require('seneca')
.use('parambulator') // not needed if Seneca 2.x
.add(
{
a: 1,
b: {required$: true}
},
function (msg, done) {
done(null, {c: msg.b})
})
.act('a:1,b:2') // valid
.act('a:1') // invalid as no b value
Any properties in the action pattern that are not constants are interpreted as_ parambulator_ rules.
Contributing
The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.
License
Copyright (c) 2016, Richard Rodger and other contributors. Licensed under MIT.