#8337 closed defect (fixed)
dojox.data.JsonRestStore Should validate schema on newItem
Reported by: | dustint | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | high | Milestone: | 1.3 |
Component: | DojoX Data | Version: | 1.2.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I was reading the code for dojox.data.JsonRestStore?. When the setValue function is called, the new value is validated against the schema, however, no such validation occurs when the new object is created.
The code should be something like: newItem: function(data,parentInfo){ .... data = new this._constructor(data); if(!dojox.json.schema.validate(data, this.schema).valid){ Do error handling } Finish the function....
Change History (5)
comment:1 Changed 12 years ago by
Owner: | changed from Jared Jurkiewicz to kriszyp |
---|
comment:2 Changed 12 years ago by
Owner: | changed from kriszyp to Kris Zyp |
---|
comment:3 Changed 12 years ago by
comment:4 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [16434]) Fixes #8337, validating new items when a dojox.json.schema is present Fixes #8362, allowing single underscore prefixed properties, but not double score prefixed properties ItemExplorer? catches error to alert the end user dojox.json.schema now has a mustBeValid that can throw an informative exception for the user dojox.rpc.JsonRest? updated to revert data properly when a HTTP request fails when saving changes
comment:5 Changed 12 years ago by
Milestone: | tbd → 1.3 |
---|
batch move of tickets marked 'tbd' fixed in the 1.3 timeframe
The hesitation I had here was that if an object was created with required properties, the user may wish to set the values via setValue rather than newItem. For example: schema={
}; store = new dojox.data.JsonRestStore?({target:"/Data/",schema:schema}); var newItem = store.newItem(); newItem.setValue(newItem, "state", "UT"); provide the state property store.save(); However, we could just insist that the required properties be provided in the newItem's parameter.