Skip to content

Commit

Permalink
Add benchmarking for dependency check
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsup committed Oct 22, 2022
1 parent 5530c24 commit 1c4a71d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"benchmark": "^2.1.4",
"chalk": "^2.4.1",
"cli-table": "^0.3.1",
"d3-format": "^1.3.2"
"d3-format": "^1.3.2",
"joi": "^17.6.4"
}
}
46 changes: 46 additions & 0 deletions benchmarks/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ module.exports = (Joi) => [
}).unknown(false).prefs({ convert: false }),
{ id: '1', level: 'info' },
{ id: '2', level: 'warning' }
],
17: () => [
Joi.object({
id: Joi.string().required(),
level: Joi.string()
.valid('debug', 'info', 'notice')
.required()
}).unknown(false).prefs({ convert: false }),
{ id: '1', level: 'info' },
{ id: '2', level: 'warning' }
]
},
(schema, value) => schema.validate(value)
Expand Down Expand Up @@ -71,6 +81,31 @@ module.exports = (Joi) => [
.optional(),
16: () =>

Joi.object({
foo: Joi.array().items(
Joi.boolean().required(),
Joi.string().allow(''),
Joi.symbol()
).single().sparse().required(),
bar: Joi.number().min(12).max(353).default(56).positive(),
baz: Joi.date().timestamp('unix'),
qux: [Joi.function().minArity(12).strict(), Joi.binary().max(345)],
quxx: Joi.string().ip({ version: ['ipv6'] }),
quxxx: [554, 'azerty', true]
})
.xor('foo', 'bar')
.or('bar', 'baz')
.pattern(/b/, Joi.when('a', {
is: true,
then: Joi.prefs({ messages: { 'any.required': 'oops' } })
}))
.meta('foo')
.strip()
.default(() => 'foo')
.optional(),

17: () =>

Joi.object({
foo: Joi.array().items(
Joi.boolean().required(),
Expand Down Expand Up @@ -153,5 +188,16 @@ module.exports = (Joi) => [
{ id: 1, level: 'info', tags: [true, false] }
],
(schema, value) => schema.validate(value)
],
[
'Dependency validation',
() => [
Joi.object({
'a': Joi.string(),
'b': Joi.string()
}),
{ a: 'foo', b: 'bar' }
],
(schema, value) => schema.validate(value)
]
];

0 comments on commit 1c4a71d

Please sign in to comment.