Last active
January 2, 2016 02:29
-
-
Save tautologistics/8237623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tv4 = require('tv4'); | |
var schema = { | |
"type": "object", | |
"$schema": "http://json-schema.org/draft-04/schema", | |
"id": "#", | |
"required": ["events"], | |
"properties": { | |
"events": { | |
"type": "array", | |
"minItems": 1, | |
"not": { | |
"items": { | |
"type": "object", | |
"required": ["event_name"], | |
"properties": { | |
"event_name": { | |
"type": "string", | |
"not": { | |
"enum": ["inventory sent"] | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}; | |
var data = { | |
"events":[ | |
{ "event_name": "foo" }, | |
{ "event_name": "inventory sent" }, | |
{ "event_name": "foo" } | |
] | |
}; | |
console.log(tv4.validateMultiple(data, schema)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been looking for a good example on this. Thanks!