Skip to content

Instantly share code, notes, and snippets.

@samueljoli
Created January 30, 2017 18:06
Show Gist options
  • Select an option

  • Save samueljoli/f8d9f15536d5e6ddd5eab944b13fbb39 to your computer and use it in GitHub Desktop.

Select an option

Save samueljoli/f8d9f15536d5e6ddd5eab944b13fbb39 to your computer and use it in GitHub Desktop.
const documentSchema = Joi.object().keys({/*property definitions here*/});
Joi.validate(document, documentSchema, function(err, value) {
if (err) {
throw new Error(‘Document failed validation’);
} else {
// write doc to PG
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment