function(newDoc, oldDoc, userCtx) {
  
  if (oldDoc){
    if (userCtx.roles.indexOf("_admin") == -1) {
      throw({forbidden: "Only database admins are allowed to update pastes/comments"});
    }
  }
} 

@@ -33,11 +33,8 @@
 ) %7B%0A
-  %0A
   if
@@ -187,15 +187,359 @@
 ;%0A    %7D%0A
+  %7D else %7B%0A    // verify well-formedness%0A%0A    var malformed = false;%0A    if (typeof(newDoc.data) != %22string%22) %7B%0A      malformed = true;%0A    %7D else if (%5B%22paste%22, %22comment%22%5D.indexOf(newDoc.type) == -1) %7B%0A      malformed = true;%0A    %7D%0A%0A    if (malformed == true) %7B%0A      throw(%7Bforbidden: %22The document is malformed. Not accepting this.%22%7D);%0A    %7D%0A
   %7D%0A%7D %0A

Add basic well-formedness verification before storing a doc