import joi from "joi"; const extSchema = joi.object().keys({ auctionid_str: joi.string().required(), inventory_source: joi.number().integer(), }); const geoSchema = joi.object().keys({ city: joi.string().allow(""), country: joi.string().min(3).max(3).case("upper").allow(""), }); const deviceSchema = joi.object().keys({ model: joi.string().allow(""), language: joi.string().allow(""), os: joi.string().allow(""), connectiontype: joi.number().integer(), carrier: joi.string().allow(""), ip: joi.string().ip({ version: "ipv4" }).required(), ua: joi.string().allow(""), osv: joi.string(), geo: geoSchema, }); const appSchema = joi.object().keys({ bundle: joi.string(), name: joi.string(), }); const impSchema = joi.object().keys({ bidfloor: joi.number().min(0), }); const bidRequestSchema = joi.object().keys({ imp: joi.array().items(impSchema).length(1).required(), device: deviceSchema, app: appSchema, at: joi.number().integer(), ext: extSchema, }); const adcandidatesSchema = joi.object().keys({ line_item_alternative_id: joi.string().required(), }); export const externalOpenRtbRequestSchema = joi .object() .keys({ bid_request: bidRequestSchema, adcandidates: joi.array().items(adcandidatesSchema).min(1).required(), }) .options({ allowUnknown: true });