https://github.com/marcbachmann/metalman-schema
https://github.com/marcbachmann/metalman-schema
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/marcbachmann/metalman-schema
- Owner: marcbachmann
- Created: 2016-10-27T22:48:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T02:29:33.000Z (over 2 years ago)
- Last Synced: 2024-04-14T14:40:25.594Z (about 2 years ago)
- Language: JavaScript
- Size: 175 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# metalman-schema
[](https://greenkeeper.io/)
A JSON schema validation middleware for the metalman module.
```js
var metalman = require('metalman')
var action = require('metalman-action')
var command = metalman([validate])
var fn = command({
schema: {
type: 'object',
required: ['foo'],
additionalProperties: false,
properties: {
foo: {type: 'number'}
}
}
})
fn({foo: 'bar'}, function (err) {
// err instanceof Error
// err.name equals 'ValidationError'
// err.message equals "Value at path '/foo' should be number"
})
fn({foo: 1}, function (err) {
// err equals null if the schema is valid
})
```