Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Comment on "Validations functions" #400

jeroenvandijk opened this Issue · 1 comment

2 participants

Jeroen van Dijk Ido Ran
Jeroen van Dijk

The unchanged validation function doesn't seem to allow deletion of docs. I think it should be the following instead (note the _delete check):

function (newDoc, oldDoc, userCtx) {
  function unchanged(field) {
    if (oldDoc && !newDoc._deleted && toJSON(oldDoc[field]) != toJSON(newDoc[field]))
      throw({forbidden : "Field can't be changed: " + field});

This will not allow changes to the created_at field, but does allow deletion.

Ido Ran

You should also check the very important author field otherwise the whole point of limit only the author to be able to change the document has gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.