Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
Created April 8, 2016 20:06
Show Gist options
  • Save mrlannigan/59237d5b7f1cdeb002da24f00c97ddb5 to your computer and use it in GitHub Desktop.
Save mrlannigan/59237d5b7f1cdeb002da24f00c97ddb5 to your computer and use it in GitHub Desktop.
//////////////////////////////////////////////////
// mapping example
var x = {
validate: {
type: 'joi',
key: 'somekey'
}
}
// sidebar: the mapping example
mapping.somekey = Joi.object().keys({
a: Joi.string().length(5)
})
//end sidebar
z = mapping[x.validate.key];
//////////////////////////////////////////////////
// custom compile example
var y = {
validate: {
type: 'joi',
schema: {
pie: /^.+/
}
}
}
z = Joi.compile(y.validate.schema);
//////////////////////////////////////////////////
// both cases do this
z.validate({pie: 'test'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment