Skip to content

Commit

Permalink
Merge pull request #767 from blackflux/dev
Browse files Browse the repository at this point in the history
[Gally]: master <- dev
  • Loading branch information
simlu committed Dec 18, 2020
2 parents 1c92ac9 + 08465c3 commit 5109d22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
@@ -1,6 +1,6 @@
const Joi = require('@hapi/joi').defaults((schema) => schema.options({
presence: 'required',
convert: false
convert: true
}));

module.exports = {
Expand All @@ -12,5 +12,6 @@ module.exports = {
},
...Joi,
boolean: (...args) => Joi.boolean(...args).strict(),
number: (...args) => Joi.number(...args).strict()
number: (...args) => Joi.number(...args).strict(),
string: (...args) => Joi.string(...args).strict()
};
10 changes: 10 additions & 0 deletions test/index.spec.js
Expand Up @@ -115,4 +115,14 @@ describe('Testing Strict Mode', () => {
expect(Joi.test('str', Joi.string().lowercase())).to.equal(true);
});
});

describe('Testing Joi.date() accepts string', () => {
it('Testing string allowed', () => {
expect(Joi.test('2020-06-04T09:42:17-07:00', Joi.date())).to.equal(true);
});

it('Testing date allowed', () => {
expect(Joi.test(new Date(), Joi.date())).to.equal(true);
});
});
});

0 comments on commit 5109d22

Please sign in to comment.