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 CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- version -->
2
- # 6.10.0 API Reference
2
+ # 6.10.1 API Reference
3
3
  <!-- versionstop -->
4
4
 
5
5
  <img src="https://raw.github.com/hapijs/joi/master/images/validation.png" align="right" />
package/lib/any.js CHANGED
@@ -530,7 +530,7 @@ internals.Any.prototype._validate = function (value, state, options, reference)
530
530
  }
531
531
  }
532
532
  else {
533
- finalValue = self._flags.default;
533
+ finalValue = Hoek.clone(self._flags.default);
534
534
  }
535
535
  }
536
536
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "joi",
3
3
  "description": "Object schema validation",
4
- "version": "6.10.0",
4
+ "version": "6.10.1",
5
5
  "repository": "git://github.com/hapijs/joi",
6
6
  "main": "lib/index.js",
7
7
  "keywords": [
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({