Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Comment on "Validations functions" #400

Open
jeroenvandijk opened this Issue · 1 comment

2 participants

@jeroenvandijk

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});
  }
  unchanged("created_at");
}

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.