joi 6.10.0 → 6.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +1 -1
- package/lib/any.js +1 -1
- package/package.json +1 -1
- package/test/any.js +25 -0
package/API.md
CHANGED
package/lib/any.js
CHANGED
package/package.json
CHANGED
package/test/any.js
CHANGED
|
@@ -552,6 +552,31 @@ describe('any', function () {
|
|
|
552
552
|
], done);
|
|
553
553
|
});
|
|
554
554
|
|
|
555
|
+
it('should set default value as a clone', function (done) {
|
|
556
|
+
|
|
557
|
+
var defaultValue = { bar: 'val' };
|
|
558
|
+
var schema = Joi.object({ foo: Joi.object().default(defaultValue) });
|
|
559
|
+
var input = {};
|
|
560
|
+
|
|
561
|
+
schema.validate(input, function (err, value) {
|
|
562
|
+
|
|
563
|
+
expect(err).to.not.exist();
|
|
564
|
+
expect(value.foo).to.not.equal(defaultValue);
|
|
565
|
+
expect(value.foo).to.only.deep.include({ bar: 'val' });
|
|
566
|
+
|
|
567
|
+
value.foo.bar = 'mutated';
|
|
568
|
+
|
|
569
|
+
schema.validate(input, function (err2, value2) {
|
|
570
|
+
|
|
571
|
+
expect(err2).to.not.exist();
|
|
572
|
+
expect(value2.foo).to.not.equal(defaultValue);
|
|
573
|
+
expect(value2.foo).to.only.deep.include({ bar: 'val' });
|
|
574
|
+
|
|
575
|
+
done();
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
|
|
555
580
|
it('should not apply default values if the noDefaults option is enquire', function (done) {
|
|
556
581
|
|
|
557
582
|
var schema = Joi.object({
|