-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codefeatureNew functionality or improvementNew functionality or improvement
Milestone
Description
Context
- node version: 4.3.0
- joi version: 8.0.5
- environment: node
What are you trying to achieve or the steps to reproduce?
Use any.label() on a schema within an array, or on the array schema directly.
We use Joi to validate our API responses, so it's common that we are validating large arrays.
const Joi = require('joi');
const users = getUsers();
const schema = Joi.array().items(
Joi.object().keys({
username: Joi.string().required()
})
);
console.time('without label');
Joi.validate(users, schema);
console.timeEnd('without label');
console.time('with label');
Joi.validate(users, schema.label('Users'));
console.timeEnd('with label');
///
function getUsers() {
const users = [];
for (var i=0; i<10000; i++) {
users.push({username: 'example'});
}
return users;
}Which result you had?
A significant impact on validation performance:
without label: 163ms
with label: 448ms
What did you expect?
No noticeable impact on performance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codefeatureNew functionality or improvementNew functionality or improvement