Skip to content

Instantly share code, notes, and snippets.

@patrobinson
Created October 31, 2014 04:30
Show Gist options
  • Save patrobinson/c82437b33619991de889 to your computer and use it in GitHub Desktop.
Save patrobinson/c82437b33619991de889 to your computer and use it in GitHub Desktop.
function(newDoc, oldDoc, userCtx, secObj) {
for (var field in newDoc) {
if(/^_/.test(field) == false && typeof newDoc[field] == "string") {
if(/^(\{|\[)/.test(newDoc[field])) {
throw ({forbidden : field + " field doesn't contain valid JSON:\n" + newDoc[field]});
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment