Joi.object().keys({ dimension: id, member: id, operator: Joi.valid(operators).required(), values: Joi.array().items(Joi.string().allow('', null), Joi.lazy(() => oneFilter)) }).xor('dimension', 'member')
Joi.object().keys({ or: Joi.array().items(oneFilter, Joi.lazy(() => oneCondition).description('oneCondition schema')), and: Joi.array().items(oneFilter, Joi.lazy(() => oneCondition).description('oneCondition schema')), }).xor('or', 'and')
Joi.object().keys({ title: Joi.string(), description: Joi.string(), dimensions: Joi.func(), segments: Joi.func(), order: Joi.array().items(Joi.object().keys({ member: Joi.func().required(), direction: Joi.any().valid('asc', 'desc').required() })), filters: Joi.array().items(Joi.object().keys({ member: Joi.func().required(), operator: Joi.any().valid('contains', 'notContains', 'equals', 'set', 'notSet', 'gt', 'gte', 'lt', 'lte'), params: Joi.array().items(Joi.string().allow('').optional()) })), timeDimension: Joi.object().keys({ dimension: Joi.func().required(), dateRange: Joi.string().required(), granularity: Joi.any().valid('hour', 'day', 'week', 'month', 'year', null) }), visualization: Joi.object().keys({ type: Joi.any().valid('bar', 'line', 'table', 'area', 'singleValue', 'pie').required(), autoScale: Joi.boolean(), seriesPositioning: Joi.any().valid('stacked', 'grouped', 'proportional') }), pivot: Joi.object().keys({ x: Joi.array(), y: Joi.array() }),
/** * Get the Trigger configuration schema. * @returns {*} */ getConfigurationSchema() { return this.joi.object().keys({ mock: this.joi.string().default('mock'), }); }
/** * Get the Trigger configuration schema. * @returns {*} */ getConfigurationSchema() { return this.joi.object().keys({ host: [this.joi.string().hostname().required(), this.joi.string().ip().required()], port: this.joi.number().port().required(), user: this.joi.string().required(), pass: this.joi.string().required(), from: this.joi.string().email().required(), to: this.joi.string().email().required(), }); }
lab.experiment('Validation', () => { lab.test('it returns the Joi validation results of a SubClass', () => { class DummyModel extends MongoModels {} DummyModel.schema = Joi.object().keys({ name: Joi.string().required() }); lab.expect(DummyModel.validate()).to.be.an.object(); }); lab.test('it returns the Joi validation results of a SubClass instance', () => { class DummyModel extends MongoModels {} DummyModel.schema = Joi.object().keys({ name: Joi.string().required() }); const dummy = new DummyModel({ name: 'Stimpy' }); lab.expect(dummy.validate()).to.be.an.object(); }); });
lab.before(async () => { DummyModel = class extends MongoModels {}; DummyModel.schema = Joi.object().keys({ _id: Joi.object(), count: Joi.number(), group: Joi.string(), isCool: Joi.boolean(), name: Joi.string().required() }); DummyModel.collectionName = 'dummies'; await MongoModels.connect(config.connection, config.options); });
// Updating the delivery informations async update(req, res) { const schema = Joi.object().keys({ status: Joi.string(), message: Joi.string(), }); // Input data validation const { err } = schema.validate(req.body); if (err) { return res.status(422).json({ err: err.details }); } // Finding and validation the current delivery data const { delivery_id } = req.params; const delivery = await Delivery.findByPk(delivery_id); if (!delivery) return res.status(404).json({ err: 'Delivery not found' }); await delivery.update(req.body); return res.json(delivery); }
router.post('/login', async function(req, res) { const schema = Joi.object().keys({ password: Joi.string() .trim() let token = jwt.sign({ uid: user.id }, config.keys.tokenKey, { expiresIn: config.keys.tokenExpiresIn }); res.json({ user: _.pick(user, ['email', 'firstName', 'lastName', 'id', 'type']), token }); } else {
route.post('/:id/update', (req, res) => { const schema = Joi.object().keys({ fruit: Joi.string().required(), stock: Joi.number().required() }) Joi.validate(req.body, schema, (err, result) => { if (err) { console.log(err); res.send("Error"); } else { fruitModel.updateById(req.params.id, { name: req.body.fruit, stock: req.body.stock }) .then(data => { console.log(data); res.redirect("/fruits"); }) .catch(err => { console.log(err); res.send("Unexcepted error occured"); }) } }) })
async store(req, res) { const schema = Joi.object().keys({ name: Joi.string().required(), email: Joi.string()
/** * Get the Trigger configuration schema. * @returns {*} */ getConfigurationSchema() { return this.joi.object().keys({ url: this.joi.string().uri({ scheme: ['mqtt', 'mqtts', 'tcp', 'tls', 'ws', 'wss'], }).required(), topic: this.joi.string().default('wud/image'), user: this.joi.string(), password: this.joi.string(), }); }
/** * Get the Trigger configuration schema. * @returns {*} */ getConfigurationSchema() { return this.joi.object().keys({ brokers: this.joi.string().required(), topic: this.joi.string().default('wud-image'), clientId: this.joi.string().default('wud'), ssl: this.joi.boolean().default(false), authentication: this.joi.object({ type: this.joi.string() .allow('PLAIN') .allow('SCRAM-SHA-256') .allow('SCRAM-SHA-512') .default('PLAIN'), user: this.joi.string().required(), password: this.joi.string().required(), }), }); }
/* * Get the Trigger configuration schema. * @returns {*} */ getConfigurationSchema() { return this.joi.object().keys({ token: this.joi.string().required(), channel: this.joi.string().required(), }); }
/** * Get the Trigger configuration schema. * @returns {*} */ getConfigurationSchema() { return this.joi.object().keys({ key: this.joi.string().required(), event: this.joi.string().default('wud-image'), }); }