Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#8337 closed defect (fixed) 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:


I was reading the code for 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 13 years ago by Jared Jurkiewicz

Owner: changed from Jared Jurkiewicz to kriszyp

comment:2 Changed 13 years ago by Adam Peller

Owner: changed from kriszyp to Kris Zyp

comment:3 Changed 13 years ago by Kris Zyp

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={

properties:{state:{type:"string",optional:false}} state is required

}; store = new{target:"/Data/",schema:schema}); var newItem = store.newItem(); newItem.setValue(newItem, "state", "UT"); provide the state property; However, we could just insist that the required properties be provided in the newItem's parameter.

comment:4 Changed 13 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

(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 13 years ago by Adam Peller

Milestone: tbd1.3

batch move of tickets marked 'tbd' fixed in the 1.3 timeframe

Note: See TracTickets for help on using tickets.