Skip to content

Commit

Permalink
Changes approach and adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trizotti committed Oct 13, 2022
1 parent d9fea15 commit 85ff9f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,6 @@ internals.Base = class {

for (const key in args) {
let arg = args[key];
if (arg === undefined) {
delete args[key];
continue;
}

if (definition.argsByName) {
const resolver = definition.argsByName.get(key);
Expand All @@ -615,6 +611,11 @@ internals.Base = class {
}
}

if (arg === undefined) {
delete args[key];
continue;
}

args[key] = arg;
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/types/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('number', () => {
expect(() => {

Joi.number().greater();
}).to.throw('limit is required');
}).to.throw('limit must be a number or reference');
});

it('throws when limit is not a number', () => {
Expand Down Expand Up @@ -258,7 +258,7 @@ describe('number', () => {
expect(() => {

Joi.number().less();
}).to.throw('limit is required');
}).to.throw('limit must be a number or reference');
});

it('throws when limit is not a number', () => {
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('number', () => {
expect(() => {

Joi.number().max();
}).to.throw('limit is required');
}).to.throw('limit must be a number or reference');
});

it('throws when limit is not a number', () => {
Expand Down Expand Up @@ -524,7 +524,7 @@ describe('number', () => {

it('throws when limit is undefined', () => {

expect(() => Joi.number().min()).to.throw('limit is required');
expect(() => Joi.number().min()).to.throw('limit must be a number or reference');
});

it('throws when limit is not a number', () => {
Expand Down Expand Up @@ -694,7 +694,7 @@ describe('number', () => {
expect(() => {

Joi.number().multiple();
}).to.throw('base is required');
}).to.throw('base must be a positive number or reference');
});

it('throws when multiple is not a number', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/types/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -5264,7 +5264,7 @@ describe('string', () => {
expect(() => {

Joi.string().length();
}).to.throw('length limit is required');
}).to.throw('limit must be a positive integer or reference');
});

it('throws when limit is not a number', () => {
Expand Down Expand Up @@ -5473,7 +5473,7 @@ describe('string', () => {
expect(() => {

Joi.string().max();
}).to.throw('max limit is required');
}).to.throw('limit must be a positive integer or reference');
});

it('throws when limit is not a number', () => {
Expand Down Expand Up @@ -5594,7 +5594,7 @@ describe('string', () => {
expect(() => {

Joi.string().min();
}).to.throw('min limit is required');
}).to.throw('limit must be a positive integer or reference');
});

it('throws when limit is not a number', () => {
Expand Down

0 comments on commit 85ff9f8

Please sign in to comment.