Moleculer JSON Schema Validator
Validate moleculer action params via JSON Schema.
Current Version (v1.0.0)
- support json schema draft-7
- support moleculer ^0.11.x
- using ajv ^6.x.x
Install
npm install --save moleculer-json-schema-validator
Usage
// moleculer.config.js const Validator = moduleexports = ... validator:
// service.js
module.exports = {
actions: {
hello: {
params: {
properties: {
"name": {type: "string"}
},
required: ["name"]
},
handler (ctx) {
const {name} = ctx.params
return `Hello ${name}`
}
}
}
}
License
MIT