Created
July 21, 2016 06:27
-
-
Save bayleedev/8fca9274c24f350c34c6c7b34f68168d 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 Joi = require('joi'); | |
var schema = Joi.object().keys({ | |
id: Joi.any(), | |
type: Joi.string(), | |
respondsTo: Joi.func().required(), | |
script: Joi.string().required(), | |
connections: Joi.array().required(), | |
}) | |
var toValidate = { | |
id: 1, | |
type: 'RootScript', | |
respondsTo: () => {}, | |
script: 'wat', | |
connections: [2], | |
} | |
new Promise((resolve, reject) => { | |
Joi.validate(toValidate, schema, function (err, value) { | |
if (!err) return resolve() | |
reject(err.details[0].message) | |
}) | |
}).then(() => { | |
console.log('Success') | |
}).catch((error) => { | |
console.log(error) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment