Generates a type that will match one of the provided alternative schemas via the try()
method. If no schemas are added, the type will not match any value except for undefined.
Supports the same methods of the any() type.
var alt = Joi.alternatives().try(Joi.number(), Joi.string());
// or: var alt = Joi.alternatives.try([Joi.number(), Joi.string()])Alternatives can be expressed using a shorter notation.
var alt = Joi.alternatives(Joi.number(), Joi.string())
// or: var alt = Joi.alternatives.try([Joi.number(), Joi.string()])
alternativesGenerates a type that will match one of the provided alternative schemas via the
try()method. If no schemas are added, the type will not match any value except for
undefined.Supports the same methods of the
any()type.alternatives.try(schema, schema2, ...| [schema, schema2, ...])Try accepts schemas using single or multiple arguments, or as an array.
Using
.try()is optional and allows for a shorter version: