egg-validate-parse
v1.0.0
Published
validate and parse request
Downloads
2
Readme
egg-validate-parse
Install
$ npm i egg-validate-parse --save
Usage
// {app_root}/config/plugin.js
exports.validateParse = {
enable: true,
package: 'egg-validate-parse',
};
see egg-validate for base usage
validate rule
rules.test = {
id: { type: 'string', required: true, scope: 'params', name: 'innerId' }
}
scope
means where to fetch the params (body | params | query | queries | state)name
means prop name in output object
use in controller
ctx.validateParse(rules.test)
output
output is a object get all parsed params together.
see test for more detail.
Configuration
// {app_root}/config/config.default.js
exports.validateParse = {
defaultScope: 'body'
};
see config/config.default.js for more detail.
Example
Questions & Suggestions
Please open an issue here.