walmartlabs/joi — pull request #49 by yjh0502 (2013-02-09 03:53:54+00:00)
Title: Adding support of array argument in valid()

It's useful to make valid() handle array arguments, not only
seperated arguments.

Example usage case:

//This array will be used in other part of code,
//and number of payment method could be changed later.
//So, we will store list of valid payment methods in array.
var payment = ["visa", "mastercard", /*...*/];

var schema = {
//not only accepts string arguments,
//but also accepts arrays of valid cases
payment: Joi.types.String().valid(payment),

//here is an alternative form, much verbose than the upper
payment: Joi.types.String().valid.apply(Joi.types.String(), payment),
}