Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhaoyao91/moleculer-json-schema-validator
Validate moleculer action params via JSON Schema.
https://github.com/zhaoyao91/moleculer-json-schema-validator
Last synced: 2 months ago
JSON representation
Validate moleculer action params via JSON Schema.
- Host: GitHub
- URL: https://github.com/zhaoyao91/moleculer-json-schema-validator
- Owner: zhaoyao91
- Created: 2018-01-19T03:11:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-30T18:28:37.000Z (about 5 years ago)
- Last Synced: 2024-09-23T18:38:42.664Z (4 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 8
- Watchers: 2
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-moleculer - moleculer-json-schema-validator - [JSON Schema](https://json-schema.org/) validator (Mixins / Validation)
README
# Moleculer JSON Schema Validator
Validate moleculer action params via JSON Schema.
## Current Version (v1.0.0)
- support [json schema draft-7](http://json-schema.org/specification-links.html#draft-7)
- support [moleculer ^0.11.x](https://github.com/ice-services/moleculer)
- using [ajv ^6.x.x](https://github.com/epoberezkin/ajv)## Install
`npm install --save moleculer-json-schema-validator`
## Usage
```js
// moleculer.config.jsconst Validator = require('moleculer-json-schema-validator')
module.exports = {
...
validator: new Validator()
}
``````js
// service.jsmodule.exports = {
actions: {
hello: {
params: {
properties: {
"name": {type: "string"}
},
required: ["name"]
},
handler (ctx) {
const {name} = ctx.params
return `Hello ${name}`
}
}
}
}
```## License
MIT