Index: Dev/trunk/src/server/app.js
===================================================================
--- Dev/trunk/src/server/app.js	(revision 497)
+++ Dev/trunk/src/server/app.js	(revision 499)
@@ -225,5 +225,6 @@
     function putDocument(id,rev,type,doc) {
         var priv = stripAndReturnPrivates(doc);
-        if ( doc.type === type && validator(doc, schema).valid ) {
+        var valid;
+        if ( doc.type === type && (valid = validator(doc, schema)).valid ) {
             var opts = rev ? {headers:{'If-Match':'"'+rev+'"'}} : {};
             return HTTPResult.fromResponsePromise(couch.put(id,doc,opts).response,
@@ -241,5 +242,5 @@
             });
         } else {
-            return new HTTPResult(400,{error: "Document failed schema verification."});
+            return new HTTPResult(400,{error: "Document failed schema verification.", valid: valid});
         }
     }
@@ -262,5 +263,6 @@
     function postDocument(type,doc) {
         var priv = stripAndReturnPrivates(doc);
-        if ( doc.type === type && validator(doc, schema).valid ) {
+        var valid;
+        if ( doc.type === type && (valid = validator(doc, schema)).valid ) {
             return HTTPResult.fromResponsePromise(couch.post(doc).response,
                                                   handleUnknownError)
@@ -274,5 +276,5 @@
             });
         } else {
-            return new HTTPResult(400,{error: "Document failed schema verification."});
+            return new HTTPResult(400,{error: "Document failed schema verification.", valid: valid});
         }
     }
Index: Dev/trunk/src/server/config/couchdb-schema.json
===================================================================
--- Dev/trunk/src/server/config/couchdb-schema.json	(revision 497)
+++ Dev/trunk/src/server/config/couchdb-schema.json	(revision 499)
@@ -12,5 +12,5 @@
       "type": "object",
       "properties": {
-          "_id": { "type": "string", "pattern": "schemaInfo" },
+          "_id": { "type": "string", "pattern": "^schemaInfo$" },
           "_rev": { "type": "string" },
           "version": { "type": "string" }
@@ -32,5 +32,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "Question" },
+          "type": { "type": "string", "pattern": "^Question$" },
           "_id": { "type": "string" },
           "_rev": { "type": "string" },
@@ -49,5 +49,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "Survey" },
+          "type": { "type": "string", "pattern": "^Survey$" },
           "_id": { "type": "string" },
           "_rev": { "type": "string" },
@@ -63,5 +63,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "SurveyRun" },
+          "type": { "type": "string", "pattern": "^SurveyRun$" },
           "_id": { "type": "string" },
           "_rev": { "type": "string" },
@@ -82,5 +82,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "Response" },
+          "type": { "type": "string", "pattern": "^Response$" },
           "_id": { "type": "string" },
           "_rev": { "type": "string" },
@@ -112,5 +112,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "Header" },
+          "type": { "type": "string", "pattern": "^Header$" },
           "text": { "type": "string" }
         },
@@ -121,5 +121,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "Text" },
+          "type": { "type": "string", "pattern": "^Text$" },
           "text": { "type": "string" }
         },
@@ -130,5 +130,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "Divider" }
+          "type": { "type": "string", "pattern": "^Divider$" }
         },
         "additionalProperties": false
@@ -137,5 +137,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "StringInput" },
+          "type": { "type": "string", "pattern": "^StringInput$" },
           "text": { "type": "string" }
         },
@@ -146,5 +146,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "TextInput" },
+          "type": { "type": "string", "pattern": "^TextInput$" },
           "maxLength": { "type": "integer" },
           "text": { "type": "string" }
@@ -156,5 +156,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "NumberInput" },
+          "type": { "type": "string", "pattern": "^NumberInput$" },
           "min": { "type": "integer" },
           "max": { "type": "integer" },
@@ -168,5 +168,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "ScaleInput" },
+          "type": { "type": "string", "pattern": "^ScaleInput$" },
           "minLabel": { "type": "string" },
           "min": { "type": "integer" },
@@ -191,5 +191,5 @@
         "type": "object",
         "properties": {
-          "type": { "type": "string", "pattern": "MultipleChoiceInput" },
+          "type": { "type": "string", "pattern": "^MultipleChoiceInput$" },
           "allowMultiple": { "type": "boolean" },
           "items": { "type": "array", "items": {
