No validation on function setData()?
- Dominant language
- JavaScript
- Stars
- 30
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
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'}
]);
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading tests/extensions/validating-jsonSchema.js and the setData() usage shown in the issue. Determine the expected validation behavior when setData() receives external data, including the schema fields and extra properties in the example. Done means the project has an agreed behavior for validation on setData(), with corresponding tests and documentation if this feature is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100