dmodel
dmodel copied to clipboard
No validation on function setData()?
I noticed in the unit tests
dmodel-master/tests/extenstions/validating-jsonSchema.js
that you create the model and directly insert the data using setData() function. WIth no validation. I see no mentionof validation on this method available in the documentation. Is it possible to validate the data against the schema when setData(0 is called? I mean we can't always guarantee that the data will match the schema exactly if it comes from an external source. So why put it in the Model like that without checking?
var validatingMemory = (declare([Memory, Validating]))({
Model: jsonSchema({
properties: {
prime: {
type: 'boolean'
},
number: {
type: 'number',
minimum: 1,
maximum: 10
},
name: {
type: 'string',
required: true
}
}
})
});
validatingMemory.setData([
{id: 1, name: 'one', number: 1, prime: false, mappedTo: 'E'},
{id: 2, name: 'two', number: 2, prime: true, mappedTo: 'D'},
{id: 3, name: 'three', number: 3, prime: true, mappedTo: 'C'},
{id: 4, name: 'four', number: 4, even: true, prime: false, mappedTo: null},
{id: 5, name: 'five', number: 5, prime: true, mappedTo: 'A'}
]);