Ignore:
Timestamp:
12/04/12 16:29:49 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Support data validation and increase dendency separation.

Added json-schema validation before documents are saved. Acts both as
a safe-guard and as a reference of the data model.

Added directory for server related material. For now it contains scripts
to configure CouchDB and check validity of documents against the schema.

Started separating out parts that depend on the data model from parts
that do not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/store.js

    r410 r415  
    11define([
    22    'dojo/date/stamp',
     3    'dojox/json/schema',
     4    './schema',
    35    './store/CouchStore'
    4 ],function(stamp,CouchStore){
     6],function(stamp,jsonSchema,schema,CouchStore){
    57   
    6     var store = new CouchStore({target: 'data/couch/'});
     8    var store = new CouchStore({
     9        target: 'data/couch/',
     10        validate: function(object) {
     11            var result = jsonSchema.validate(object,schema);
     12            if ( result.valid ) {
     13                return true;
     14            } else {
     15                console.log("Found error ",result," for invalid object ",object);
     16                return false;
     17            }
     18        }
     19    });
    720    store.formatDate = function(date){
    821        return stamp.toISOString(date,{zulu:true});
Note: See TracChangeset for help on using the changeset viewer.