Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
joi.array().items(joi.string(), joi.number()).meta({ swaggerIndex: 1 }).min(1).max(5),
{
type: 'array',
items: { type: 'number', format: 'float' },
minItems: 1,
maxItems: 5,
}
);
simpleTest(
joi.alternatives(joi.string(), joi.number()).meta({ swaggerIndex: 1 }),
{ type: 'number', format: 'float' }
);
simpleTest(
joi.when('myRequiredField', {
is: true,
then: joi.string(),
otherwise: joi.number(),
}),
{ type: 'string' }
);
simpleTest(
joi.when('myRequiredField', {
is: true,
then: joi.string(),
otherwise: joi.number(),
}).meta({ swaggerIndex: 1 }),
{ type: 'number', format: 'float' }
);
const engineFactory = require('../engines/factory')
const Joi = require('joi')
module.exports = {
repo: Joi.string().required().description('Repository Name'),
user: Joi.string().required().description('Account/Organisation Name'),
branch: Joi.string().optional().description('Branch name'),
schedule: Joi.number().optional().default(60000).description('Update frequency (ms)'),
provider: Joi.string().required().only(engineFactory.availableEngines).description('CI Provider name'),
hideOwner: Joi.boolean().optional().default(false).description('Hide repo owner from display'),
sounds: Joi.object({
passed: Joi.string().optional().description('Sound to play on build pass'),
failed: Joi.string().optional().description('Sound to play on build fail'),
unknown: Joi.string().optional().description('Sound to play on unknown state')
}).optional().description('Sounds to play when build status changes'),
options: Joi.when('provider', {
is: 'circleci',
then: Joi.object({
auth: Joi.string().required().description('CircleCI auth token')
}).required(),
otherwise: Joi.forbidden()
})
}
const templateTypes = ['data', 'dockerimage', 'job', 'script'];
const templateInputSchema = Joi.object().keys({
protocol_version: Joi.string()
.allow('')
.default('v2'),
name: Joi.string()
.required(),
type: Joi.string()
.valid(templateTypes),
contributor: Joi.string()
.required(),
description: Joi.string()
.allow('')
.default(''),
version: Joi.when('type', {
is: 'job',
then: Joi.string(),
otherwise: Joi.string().required(),
}),
uri: Joi.when('type', {
is: 'job',
then: Joi.forbidden(),
otherwise: Joi.string().required(),
}),
usage: Joi.when('type', {
is: 'script',
then: Joi.object(),
otherwise: Joi.forbidden(),
}),
prerequisites: Joi.when('type', {
is: 'job',
version: Joi.when('type', {
is: 'job',
then: Joi.string(),
otherwise: Joi.string().required(),
}),
uri: Joi.when('type', {
is: 'job',
then: Joi.forbidden(),
otherwise: Joi.string().required(),
}),
usage: Joi.when('type', {
is: 'script',
then: Joi.object(),
otherwise: Joi.forbidden(),
}),
prerequisites: Joi.when('type', {
is: 'job',
then: Joi.array().required(),
otherwise: Joi.forbidden(),
}),
tasks: Joi.when('type', {
is: 'job',
then: Joi.array().required(),
otherwise: Joi.forbidden(),
}),
parameters: Joi
.when('type', {
is: 'data',
then: Joi.forbidden(),
})
.when('type', {
is: 'dockerimage',
constructor(props, context) {
super(props, context);
this.actions = bindActionCreators(ContractActions, this.props.dispatch);
//TODO: modify validation for nested properties
this.validatorTypes = {
id: Joi.number().required().label('Contract Id'),
description: Joi.when('finished', { is: true, then: Joi.string().min(5).max(25).required() }).label('Description'),
finished: Joi.boolean().label('Finished')
}
this.state = this.props.contract ? this.props.contract : this.initialState;
}
contributor: Joi.string()
.required(),
description: Joi.string()
.allow('')
.default(''),
version: Joi.when('type', {
is: 'job',
then: Joi.string(),
otherwise: Joi.string().required(),
}),
uri: Joi.when('type', {
is: 'job',
then: Joi.forbidden(),
otherwise: Joi.string().required(),
}),
usage: Joi.when('type', {
is: 'script',
then: Joi.object(),
otherwise: Joi.forbidden(),
}),
prerequisites: Joi.when('type', {
is: 'job',
then: Joi.array().required(),
otherwise: Joi.forbidden(),
}),
tasks: Joi.when('type', {
is: 'job',
then: Joi.array().required(),
otherwise: Joi.forbidden(),
}),
parameters: Joi
.when('type', {
function getSchemaForLang(lang) {
let schema = Joi.object().keys({
block: Joi.string(),
blockId: Joi.objectId(),
challengeOrder: Joi.number(),
challengeType: Joi.number()
.min(0)
.max(9)
.required(),
checksum: Joi.number(),
dashedName: Joi.string(),
description: Joi.when('challengeType', {
is: challengeTypes.step,
then: Joi.string().allow(''),
otherwise: Joi.string().required()
}),
fileName: Joi.string(),
files: Joi.array().items(
Joi.object().keys({
key: Joi.string(),
ext: Joi.string(),
name: Joi.string(),
head: [
Joi.array().items(Joi.string().allow('')),
Joi.string().allow('')
],
tail: [
Joi.array().items(Joi.string().allow('')),
const Joi = require('joi');
const linkSchema = require('./link');
module.exports = Joi.when('provider', {
is : 'instagram',
then : linkSchema,
otherwise: Joi.forbidden(),
});
const JoiBlockWithTransactions = JoiBlock.keys({
transactions: array().items(JoiTransaction).required()
});
const JoiTransactionReceipt = object({
transactionHash: hex256.required(),
transactionIndex: hex.required(),
blockNumber: hex.required(),
blockHash: hex256.required(),
cumulativeGasUsed: hex.required(),
gasUsed: hex.required(),
logs: array().items(JoiLog).required(),
contractAddress: address.allow(null).required(),
from: address.required(),
to: when(
'contractAddress',
{
is: null,
then: address,
otherwise: allow(null)
}
).required(),
logsBloom: hex.required(),
status: alternatives().valid('0x0', '0x1')
});
export function mustBeValidLog(log: Log): Log {
return validate(log, JoiLog);
}
export function mustBeValidBlockWithTransactionHashes(block: BlockWithTransactionHashes): BlockWithTransactionHashes {
video_url: linkSchema.optional(),
ratio : Joi.number().required(),
})).optional(),
})
.when('provider', {
is : 'weibo',
then: Joi.array().items(Joi.object({
type : Joi.string().valid('gif', 'photo').required(),
image_url: linkSchema,
})).optional(),
otherwise: Joi.forbidden(),
})
);
exports.images = (
Joi
.when('provider', {
is : 'unsplash',
then: Joi.object({
small: linkSchema,
large: linkSchema,
ratio: Joi.number().required(),
}).required(),
otherwise: Joi.forbidden(),
})
);