Skip to content

Commit

Permalink
Merge branch 'v4'
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Apr 28, 2017
2 parents 9802e23 + de9fad5 commit 3aa523e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/dot/validate.jst
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
{{?}}
{{? $rulesGroup.type }}
}
{{? $typeSchema && $typeSchema === $rulesGroup.type }}
{{? $typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes }}
{{ var $typeChecked = true; }}
else {
{{
Expand All @@ -209,7 +209,7 @@
{{~}}
{{?}}

{{? $typeSchema && !$typeChecked && !(it.opts.coerceTypes && $coerceToTypes) }}
{{? $typeSchema && !$typeChecked && !$coerceToTypes }}
{{# def.checkType }}
{{# def.error:'type' }}
}
Expand Down
19 changes: 19 additions & 0 deletions spec/coercion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,25 @@ describe('Type coercion', function () {
});


it('should generate one error for type with coerceTypes option (issue #469)', function() {
var schema = {
"type": "number",
"minimum": 10
};

instances.forEach(function (_ajv) {
var validate = _ajv.compile(schema);
validate(9). should.equal(false);
validate.errors.length .should.equal(1);

validate(11). should.equal(true);

validate('foo'). should.equal(false);
validate.errors.length .should.equal(1);
});
});


function testRules(rules, cb) {
for (var toType in rules) {
for (var fromType in rules[toType]) {
Expand Down

0 comments on commit 3aa523e

Please sign in to comment.