Skip to content

Commit

Permalink
make extensions/jsonSchema easier to work with
Browse files Browse the repository at this point in the history
fixes dojo#2
  • Loading branch information
neonstalwart committed Dec 8, 2014
1 parent 712e4cc commit fdb9368
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
7 changes: 3 additions & 4 deletions extensions/jsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ define(['../Property', '../Model', 'dojo/_base/declare', 'json-schema/lib/valida
definition['default'] = jsDefinition['default'];
}
}
return declare(Model, {
schema: modelSchema
});

return modelSchema;
};
});
});
37 changes: 20 additions & 17 deletions tests/extensions/validating-jsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,28 @@ define([
'dojo/_base/declare',
'dstore/Memory',
'dmodel/store/Validating',
'dmodel/extensions/jsonSchema'
], function (registerSuite, assert, lang, JSON, declare, Memory, Validating, jsonSchema) {
'dmodel/extensions/jsonSchema',
'dmodel/Model'
], function (registerSuite, assert, lang, JSON, declare, Memory, Validating, jsonSchema, Model) {

var validatingMemory = (declare([Memory, Validating]))({
Model: jsonSchema({
properties: {
prime: {
type: 'boolean'
},
number: {
type: 'number',
minimum: 1,
maximum: 10
},
name: {
type: 'string',
required: true
Model: Model.createSubclass({
schema: jsonSchema({
properties: {
prime: {
type: 'boolean'
},
number: {
type: 'number',
minimum: 1,
maximum: 10
},
name: {
type: 'string',
required: true
}
}
}
})
})
});
validatingMemory.setData([
Expand Down Expand Up @@ -52,7 +55,7 @@ define([
four.set('number', 3);
assert.strictEqual(four.property('number').get('errors'), undefined);
},

'put update': function () {
var four = lang.delegate(validatingMemory.getSync(4));
four.prime = 'not a boolean';
Expand Down

0 comments on commit fdb9368

Please sign in to comment.