shipharbor / merry

:ocean::ocean::sailboat::ocean::ocean: - cute streaming API framework
MIT License
312 stars 21 forks source link

json-schema middleware should disallow extra properties #50

Closed yoshuawuyts closed 7 years ago

yoshuawuyts commented 7 years ago

Right now if extra properties are appended we allow them; we probably want a strict schema. This probably means we need to enable the filter property:

var filter = validator.filter({
  required: true,
  type: 'object',
  properties: {
    hello: {type: 'string', required: true}
  },
  additionalProperties: false
})

var doc = {hello: 'world', notInSchema: true}
console.log(filter(doc)) // {hello: 'world'}
yoshuawuyts commented 7 years ago

lol, no actually if the additionalProperties flag is set it'll be all strict and throw - not an issue heyyyyy