Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 33: Allow validation to be skipped when an item has a semantically equal value #35

Merged
merged 1 commit into from
Jul 6, 2018

Conversation

OldSneerJaw
Copy link
Owner

@OldSneerJaw OldSneerJaw commented Jul 4, 2018

Description

Introduces the skipValidationWhenValueUnchanged constraint for all validation types. When enabled, validation is not performed on the property or element when it semantically equals the value from the previous revision (e.g. a datetime of "2018-06-13T18:01-07:00" is semantically equal to "2018-06-13T21:01-04:00"). The result is that, even if the property or element no longer satisfies the item constraint(s), its value will be allowed if it has not changed.

NOTE: This pull request is part 1 of 2. The next pull request will add a skipValidationWhenValueUnchangedStrict constraint that requires strict (rather than semantic) equality.

Testing

  1. Generate a validation function from skip-validation-when-value-unchanged-doc-definitions.js:
./make-validation-function -j test/resources/skip-validation-when-value-unchanged-doc-definitions.js build/test-validation-function.txt
  1. Copy and paste the generated validation function into a CouchDB design document.
  2. Create a valid dynamicSkipValidationWhenValueUnchangedDoc document (should be accepted with 201 Created):
PUT /test/skip-validation-test-1 HTTP/1.1
Host: localhost:5984
Content-Type: application/json
Authorization: Basic ********

{
	"type": "dynamicSkipValidationWhenValueUnchangedDoc",
	"allowValidationSkip": true,
	"uuidProp": "c3bb1830-12e5-4bb9-8a46-df7098c30fe0"
}
  1. Attempt to replace the document with one that fails validation because its uuidProp value is invalid and it is not equal to the old value (should be rejected with 403 Forbidden):
PUT /test/skip-validation-test-1?rev=1-5bd12c723a15dca84ea624a1b01b91bd HTTP/1.1
Host: localhost:5984
Content-Type: application/json
Authorization: Basic ********

{
	"type": "dynamicSkipValidationWhenValueUnchangedDoc",
	"allowValidationSkip": true,
	"minimumUuidValue": "d0000000-0000-0000-0000-000000000000",
	"uuidProp": "720f142a-398e-4c6c-986f-0b2df8784722"
}
  1. Replace the document with one that would fail validation if not for the fact that its uuidProp value is semantically equal to the old value (should be accepted with 201 Created):
PUT /test/skip-validation-test-1?rev=1-5bd12c723a15dca84ea624a1b01b91bd HTTP/1.1
Host: localhost:5984
Content-Type: application/json
Authorization: ********

{
	"type": "dynamicSkipValidationWhenValueUnchangedDoc",
	"allowValidationSkip": true,
	"minimumUuidValue": "d0000000-0000-0000-0000-000000000000",
	"uuidProp": "C3BB1830-12E5-4BB9-8A46-DF7098C30FE0"
}

Related Issue

…ally equal value

Introduces the `skipValidationWhenValueUnchanged` constraint for all validation types. When enabled, validation is not performed on the property or element when it semantically equals the value from the previous revision (e.g. a `datetime` of "2018-06-13T18:01-07:00" is semantically equal to "2018-06-13T21:01-04:00"). The result is that, even if the property or element no longer satisfies the item constraint(s), its value will be allowed if it has not changed.
@OldSneerJaw OldSneerJaw requested a review from dkichler July 4, 2018 23:42
@dkichler dkichler self-assigned this Jul 5, 2018
Copy link
Collaborator

@dkichler dkichler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants