kulakowka / feathers-validate-hook

Feathers hook for validate json-schema with is-my-json-valid
https://code-typing-tutor.com
MIT License
12 stars 3 forks source link

validator isnt returning anything #3

Open devSarry opened 7 years ago

devSarry commented 7 years ago

My user/hooks/index.js file looks like this

const validateHook = require('feathers-validate-hook')

// Define schema
const schema = {
  required: true,
  type: 'object',
  properties: {
    // Required attribute 'text' with type 'string'
    name: {
      required: true,
      type: 'string'
      },
    email: {
      required: true,
      type: 'string'
      }
    }
  }

exports.before = {
  all: [],
  find: [
    // auth.verifyToken(),
    // auth.populateUser(),
    // auth.restrictToAuthenticated()
  ],
  get: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    auth.restrictToOwner({ ownerField: 'id' })
  ],
  create: [
    auth.hashPassword(),
    validateHook(schema)
  ],

This is the error im getting in my client when trying to use the validator

Cannot read property 'map' of null
    at Object.<anonymous> (/home/vagrant/Code/yeller-chat/node_modules/feathers-validate-hook/lib/validate/index.js:25:34)
rof20004 commented 7 years ago

How did you correct this?