Skip to content

Commit

Permalink
describe ruleset modifiers. For #1867
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Jul 20, 2019
1 parent df67b27 commit fd518b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/manifest.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ exports.describe = function (schema) {

const item = { name: test.name };

for (const custom of ['keep', 'message', 'warn']) {
if (test[custom] !== undefined) {
item[custom] = test[custom];
}
}

if (test.args) {
item.args = {};
for (const key in test.args) {
Expand Down
16 changes: 16 additions & 0 deletions test/manifest.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,21 @@ describe('Manifest', () => {
expect(Joi.allow(1).invalid(1).describe()).to.equal({ type: 'any', invalids: [1] });
expect(Joi.invalid(1).allow(1).describe()).to.equal({ type: 'any', valids: [1] });
});

it('describes ruleset changes', () => {

const schema = Joi.string().min(1).keep();
expect(schema.describe()).to.equal({
type: 'string',
invalids: [''],
rules: [
{
name: 'min',
keep: true,
args: { limit: 1 }
}
]
});
});
});
});

0 comments on commit fd518b5

Please sign in to comment.