Skip to content

Commit 4ed756e

Browse files
committed
fix: duplicate "type" error is reported with coerceTypes option, fixes #469
1 parent 92bfeda commit 4ed756e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/dot/validate.jst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
{{?}}
142142
{{? $rulesGroup.type }}
143143
}
144-
{{? $typeSchema && $typeSchema === $rulesGroup.type }}
144+
{{? $typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes }}
145145
{{ var $typeChecked = true; }}
146146
else {
147147
{{
@@ -161,7 +161,7 @@
161161
{{~}}
162162
{{?}}
163163

164-
{{? $typeSchema && !$typeChecked && !(it.opts.coerceTypes && $coerceToTypes) }}
164+
{{? $typeSchema && !$typeChecked && !$coerceToTypes }}
165165
{{# def.checkType }}
166166
{{# def.error:'type' }}
167167
}

spec/coercion.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,14 @@ describe('Type coercion', function () {
397397
});
398398

399399

400-
it.skip('should generate one error for type with coerceTypes option (issue #469)', function() {
400+
it('should generate one error for type with coerceTypes option (issue #469)', function() {
401401
var schema = {
402402
"type": "number",
403403
"minimum": 10
404404
};
405405

406-
instances.forEach(function (ajv) {
407-
var validate = ajv.compile(schema);
406+
instances.forEach(function (_ajv) {
407+
var validate = _ajv.compile(schema);
408408
validate(9). should.equal(false);
409409
validate.errors.length .should.equal(1);
410410

0 commit comments

Comments
 (0)