Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No validation on function setData()? #12

Open
erotavlas opened this issue Aug 16, 2016 · 0 comments
Open

No validation on function setData()? #12

erotavlas opened this issue Aug 16, 2016 · 0 comments

Comments

@erotavlas
Copy link
Contributor

erotavlas commented Aug 16, 2016

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'}
]);
@erotavlas erotavlas changed the title No validation on Model setData()? No validation on function setData()? Aug 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant