Skip to content

Commit

Permalink
Merge a87b207 into 47c9bd0
Browse files Browse the repository at this point in the history
  • Loading branch information
msiebuhr authored Jan 6, 2017
2 parents 47c9bd0 + a87b207 commit 98ec877
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions schemasaurus.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,9 @@ SchemaPartProcessor.prototype.processProperties = function (step) {
for (k in step.schema.properties) {
if (step.schema.properties.hasOwnProperty(k)) {
newvar = this.createVar();
this.code("%% = %% ? %%.%% : undefined", newvar, step.varName, step.varName, k);
this.code("%% = %% ? %%['%%'] : undefined", newvar, step.varName, step.varName, k);
if (!this.options.ignoreAdditionalItems) {
this.code("%%.%% = true", propsVar, k);
this.code("%%['%%'] = true", propsVar, k);
}
step.next(step.schema.properties[k], newvar, k);
}
Expand Down
4 changes: 2 additions & 2 deletions src/int/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ SchemaPartProcessor.prototype.processProperties = function (step) {
for (k in step.schema.properties) {
if (step.schema.properties.hasOwnProperty(k)) {
newvar = this.createVar();
this.code("%% = %% ? %%.%% : undefined", newvar, step.varName, step.varName, k);
this.code("%% = %% ? %%['%%'] : undefined", newvar, step.varName, step.varName, k);
if (!this.options.ignoreAdditionalItems) {
this.code("%%.%% = true", propsVar, k);
this.code("%%['%%'] = true", propsVar, k);
}
step.next(step.schema.properties[k], newvar, k);
}
Expand Down
11 changes: 11 additions & 0 deletions test/validator_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ describe("validator", function() {
});
});

describe("for object type", function() {
it("shall not die on types with dashes", function() {
schema({
type: 'object',
properties:{ "with-dash": {type: "boolean"} }
})
.validate({'with-dash': true}, Ok)
.validate({'with-dash': false}, Ok)
});
});

describe("for numeric types", function() {
it("shall distinguish integer values", function() {
schema({type: "integer"})
Expand Down

0 comments on commit 98ec877

Please sign in to comment.