4.0.2 • Published 5 months ago

metalman-schema v4.0.2

Weekly downloads
588
License
ISC
Repository
github
Last release
5 months ago

metalman-schema

Greenkeeper badge

A JSON schema validation middleware for the metalman module.

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
})
4.0.2

5 months ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.0

3 years ago

2.0.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

8 years ago