feathers-validate-hook

0.0.7 • Public • Published

feathers-validate-hook

npm package

NPM version Dependency Status

This is experiment. Work in progress!

Feathers hook for validate json-schema with is-my-json-valid

const validateHook = require('feathers-validate-hook')
 
// Define schema 
const schema = {
  // Required attribute 'text' with type 'string'
  text: {
    required: true,
    type: 'string'
  }
}
 
app.service('/messages').before({
  create: [ 
    validateHook(schema)
  ]
})

Example

Look example folder for more information.

Test request:

curl -H "Accept: application/json" -X POST http://localhost:3030/messages

Server response example:

{
  "name": "BadRequest",
  "message": "Validation failed",
  "code": 400,
  "className": "bad-request",
  "data": {},
  "errors": [
    {
      "field": "data.text",
      "message": "is required",
      "type": "string"
    }
  ]
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.72latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.72
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i feathers-validate-hook

Weekly Downloads

0

Version

0.0.7

License

MIT

Last publish

Collaborators

  • kulakowka