- Timestamp:
- 03/10/14 11:50:04 (11 years ago)
- Location:
- Dev/trunk/src/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/server/app.js
r497 r499 225 225 function putDocument(id,rev,type,doc) { 226 226 var priv = stripAndReturnPrivates(doc); 227 if ( doc.type === type && validator(doc, schema).valid ) { 227 var valid; 228 if ( doc.type === type && (valid = validator(doc, schema)).valid ) { 228 229 var opts = rev ? {headers:{'If-Match':'"'+rev+'"'}} : {}; 229 230 return HTTPResult.fromResponsePromise(couch.put(id,doc,opts).response, … … 241 242 }); 242 243 } else { 243 return new HTTPResult(400,{error: "Document failed schema verification." });244 return new HTTPResult(400,{error: "Document failed schema verification.", valid: valid}); 244 245 } 245 246 } … … 262 263 function postDocument(type,doc) { 263 264 var priv = stripAndReturnPrivates(doc); 264 if ( doc.type === type && validator(doc, schema).valid ) { 265 var valid; 266 if ( doc.type === type && (valid = validator(doc, schema)).valid ) { 265 267 return HTTPResult.fromResponsePromise(couch.post(doc).response, 266 268 handleUnknownError) … … 274 276 }); 275 277 } else { 276 return new HTTPResult(400,{error: "Document failed schema verification." });278 return new HTTPResult(400,{error: "Document failed schema verification.", valid: valid}); 277 279 } 278 280 } -
Dev/trunk/src/server/config/couchdb-schema.json
r493 r499 12 12 "type": "object", 13 13 "properties": { 14 "_id": { "type": "string", "pattern": " schemaInfo" },14 "_id": { "type": "string", "pattern": "^schemaInfo$" }, 15 15 "_rev": { "type": "string" }, 16 16 "version": { "type": "string" } … … 32 32 "type": "object", 33 33 "properties": { 34 "type": { "type": "string", "pattern": " Question" },34 "type": { "type": "string", "pattern": "^Question$" }, 35 35 "_id": { "type": "string" }, 36 36 "_rev": { "type": "string" }, … … 49 49 "type": "object", 50 50 "properties": { 51 "type": { "type": "string", "pattern": " Survey" },51 "type": { "type": "string", "pattern": "^Survey$" }, 52 52 "_id": { "type": "string" }, 53 53 "_rev": { "type": "string" }, … … 63 63 "type": "object", 64 64 "properties": { 65 "type": { "type": "string", "pattern": " SurveyRun" },65 "type": { "type": "string", "pattern": "^SurveyRun$" }, 66 66 "_id": { "type": "string" }, 67 67 "_rev": { "type": "string" }, … … 82 82 "type": "object", 83 83 "properties": { 84 "type": { "type": "string", "pattern": " Response" },84 "type": { "type": "string", "pattern": "^Response$" }, 85 85 "_id": { "type": "string" }, 86 86 "_rev": { "type": "string" }, … … 112 112 "type": "object", 113 113 "properties": { 114 "type": { "type": "string", "pattern": " Header" },114 "type": { "type": "string", "pattern": "^Header$" }, 115 115 "text": { "type": "string" } 116 116 }, … … 121 121 "type": "object", 122 122 "properties": { 123 "type": { "type": "string", "pattern": " Text" },123 "type": { "type": "string", "pattern": "^Text$" }, 124 124 "text": { "type": "string" } 125 125 }, … … 130 130 "type": "object", 131 131 "properties": { 132 "type": { "type": "string", "pattern": " Divider" }132 "type": { "type": "string", "pattern": "^Divider$" } 133 133 }, 134 134 "additionalProperties": false … … 137 137 "type": "object", 138 138 "properties": { 139 "type": { "type": "string", "pattern": " StringInput" },139 "type": { "type": "string", "pattern": "^StringInput$" }, 140 140 "text": { "type": "string" } 141 141 }, … … 146 146 "type": "object", 147 147 "properties": { 148 "type": { "type": "string", "pattern": " TextInput" },148 "type": { "type": "string", "pattern": "^TextInput$" }, 149 149 "maxLength": { "type": "integer" }, 150 150 "text": { "type": "string" } … … 156 156 "type": "object", 157 157 "properties": { 158 "type": { "type": "string", "pattern": " NumberInput" },158 "type": { "type": "string", "pattern": "^NumberInput$" }, 159 159 "min": { "type": "integer" }, 160 160 "max": { "type": "integer" }, … … 168 168 "type": "object", 169 169 "properties": { 170 "type": { "type": "string", "pattern": " ScaleInput" },170 "type": { "type": "string", "pattern": "^ScaleInput$" }, 171 171 "minLabel": { "type": "string" }, 172 172 "min": { "type": "integer" }, … … 191 191 "type": "object", 192 192 "properties": { 193 "type": { "type": "string", "pattern": " MultipleChoiceInput" },193 "type": { "type": "string", "pattern": "^MultipleChoiceInput$" }, 194 194 "allowMultiple": { "type": "boolean" }, 195 195 "items": { "type": "array", "items": {
Note: See TracChangeset
for help on using the changeset viewer.