Skip to content

Instantly share code, notes, and snippets.

@cadecairos
Created July 21, 2015 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cadecairos/71d12e26fd68a8dbba71 to your computer and use it in GitHub Desktop.
Save cadecairos/71d12e26fd68a8dbba71 to your computer and use it in GitHub Desktop.
var schema = Joi.array().items(
Joi.object().keys({
a: Joi.string().valid('1', '2', '3'),
b: Joi.string().valid('a', 'b', 'c'),
c: Joi.object().keys({
// Does this work?
// if not, how do I reference 'a' properly?
d: Joi.any().when('a', {
is: '1',
then: Joi.required(),
otherwise: Joi.forbidden()
})
})
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment