Skip to content

Instantly share code, notes, and snippets.

@nvcexploder
Created February 11, 2014 00:47
Show Gist options
  • Save nvcexploder/8927290 to your computer and use it in GitHub Desktop.
Save nvcexploder/8927290 to your computer and use it in GitHub Desktop.
Route validation config showing nested Joi configuration objects
exports.create = {
description: 'Creates a new cart',
validate: {
payload: {
location: Joi.object({
postalCode: Joi.string().required().description('Postal Code'),
city: Joi.string().optional().description('City'),
state: Joi.string().optional().description('State or Province Code'),
country: Joi.string().optional().description('Country')
}).optional().description('Cart Location'),
storeFrontId: Joi.object({
USStoreId: Joi.number().required().description('US Store ID')
}).optional().description('StoreFront ID'),
currencyCode: Joi.string().optional().description('Currency Code'),
customerId: Joi.string().optional().description('Customer UUID')
},
failAction: 'log'
},
handler: function createCart (request, reply) {
reply(new Cart());
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment