js-schema
js-schema copied to clipboard
How to validate only given properties exist?
How do we specify that any fields other than the ones specified are not allowed? SO, f.e., I want this:
var Thing = schema({
foo: Number
})
Thing({foo: 5}) // true
Thing({foo: 5, bar: "blah"}) // false, because `blah` isn't a specified property.
This might be way to late for an answer, but I found myself looking for the same answer and ended up using something like this:
Thing:{ "*":Object.like(undefined), foo:5 }