Skip to content

zhaoyao91/moleculer-json-schema-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moleculer JSON Schema Validator

Validate moleculer action params via JSON Schema.

Current Version (v1.0.0)

Install

npm install --save moleculer-json-schema-validator

Usage

// moleculer.config.js

const Validator = require('moleculer-json-schema-validator')

module.exports = {
  ...
  validator: new 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

About

Validate moleculer action params via JSON Schema.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published