Skip to content

Instantly share code, notes, and snippets.

@makishvili
Created September 1, 2017 16:07
Show Gist options
  • Save makishvili/e9ec6882382a722eb96ccf0e8e9a136b to your computer and use it in GitHub Desktop.
Save makishvili/e9ec6882382a722eb96ccf0e8e9a136b to your computer and use it in GitHub Desktop.
function getValidationFields() {
return {
body: {
companies_ids: joi.array().required(),
start_time: joi.date().required(),
duration: joi.date().required(),
contact_info: {
person_name: joi.string().required(),
phone: joi.string().required(),
email: joi.string().email()
},
ads: {
ru: {
lang: joi.any().tags(['ru', 'uk', 'be', 'kk', 'tr']).required(),
title: joi.string().required(),
text: joi.string().required(),
url: joi.string().uri({scheme: ['http', 'https']}),
extra: joi.string(),
logo: joi.object({
width: joi.number().integer(),
height: joi.number().integer(),
href: joi.string().uri({scheme: ['http', 'https'], allowRelative: true}),
bytesize: joi.number().integer(),
bgcolor: joi.string()
}).and('width', 'height', 'href'),
main_photo: joi.object({
width: joi.number().integer(),
height: joi.number().integer(),
href: joi.string().uri({scheme: ['http', 'https'], allowRelative: true}),
bytesize: joi.number().integer()
}).and('width', 'height', 'href'),
products: joi.object({
items: joi.array().items(joi.object({
photo: joi.object({
width: joi.number().integer(),
height: joi.number().integer(),
href: joi.string().uri({scheme: ['http', 'https'], allowRelative: true}),
bytesize: joi.number().integer()
}).and('width', 'height', 'href'),
title: joi.string(),
price: joi.number(),
url: joi.string()
}).and('photo', 'title', 'price', 'url')),
currency: joi.any().tags(['rub', 'kzt', 'uah', 'byn']).required()
}),
about: joi.string(),
promo: joi.object({
startTime: joi.date(),
stopTime: joi.date(),
title: joi.string(),
banner: joi.object({
width: joi.number().integer(),
height: joi.number().integer(),
href: joi.string().uri({scheme: ['http', 'https'], allowRelative: true}),
bytesize: joi.number().integer()
}).and('width', 'height', 'href'),
details: joi.string(),
disclaimer: joi.string(),
url: joi.string().uri({scheme: ['http', 'https']})
}).and('title', 'details', 'url')
}
},
status: joi.any().tags(['draft', 'ready'])
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment