-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from OldSneerJaw/issue-33-unchanged-values
Issue 33: Allow validation to be skipped when an item has a semantically equal value
- Loading branch information
Showing
8 changed files
with
513 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
test/resources/skip-validation-when-value-unchanged-doc-definitions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
function() { | ||
return { | ||
staticSkipValidationWhenValueUnchangedDoc: { | ||
typeFilter: simpleTypeFilter, | ||
authorizedRoles: { write: 'write' }, | ||
propertyValidators: { | ||
integerProp: { | ||
type: 'integer', | ||
skipValidationWhenValueUnchanged: true, | ||
minimumValue: 0 | ||
}, | ||
floatProp: { | ||
type: 'float', | ||
skipValidationWhenValueUnchanged: true, | ||
maximumValue: 0 | ||
}, | ||
stringProp: { | ||
type: 'string', | ||
skipValidationWhenValueUnchanged: true, | ||
minimumLength: 4 | ||
}, | ||
booleanProp: { | ||
type: 'boolean', | ||
skipValidationWhenValueUnchanged: true, | ||
customValidation: function(doc, oldDoc, currentItemEntry) { | ||
if (isValueNullOrUndefined(currentItemEntry.itemValue) || currentItemEntry.itemValue) { | ||
return [ ]; | ||
} else { | ||
return [ currentItemEntry.itemName + ' must be true' ]; | ||
} | ||
} | ||
}, | ||
dateProp: { | ||
type: 'date', | ||
skipValidationWhenValueUnchanged: true, | ||
maximumValue: '1953-01-14' | ||
}, | ||
datetimeProp: { | ||
type: 'datetime', | ||
skipValidationWhenValueUnchanged: true, | ||
minimumValue: '2018-06-13T23:33+00:00', | ||
maximumValue: '2018-06-13T23:33Z' | ||
}, | ||
timeProp: { | ||
type: 'time', | ||
skipValidationWhenValueUnchanged: true, | ||
minimumValueExclusive: '17:45:53.911' | ||
}, | ||
timezoneProp: { | ||
type: 'timezone', | ||
skipValidationWhenValueUnchanged: true, | ||
maximumValueExclusive: '+15:30' | ||
}, | ||
enumProp: { | ||
type: 'enum', | ||
predefinedValues: [ 1, 2, 3 ], | ||
skipValidationWhenValueUnchanged: true | ||
}, | ||
uuidProp: { | ||
type: 'uuid', | ||
skipValidationWhenValueUnchanged: true, | ||
maximumValueExclusive: '10000000-0000-0000-0000-000000000000' | ||
}, | ||
attachmentReferenceProp: { | ||
type: 'attachmentReference', | ||
skipValidationWhenValueUnchanged: true, | ||
regexPattern: /^[a-z]+\.txt$/ | ||
}, | ||
arrayProp: { | ||
type: 'array', | ||
skipValidationWhenValueUnchanged: true, | ||
maximumLength: 3 | ||
}, | ||
objectProp: { | ||
type: 'object', | ||
skipValidationWhenValueUnchanged: true, | ||
propertyValidators: { | ||
nestedProp: { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
hashtableProp: { | ||
type: 'hashtable', | ||
skipValidationWhenValueUnchanged: true, | ||
hashtableValuesValidator: { | ||
type: 'integer' | ||
} | ||
} | ||
} | ||
}, | ||
dynamicSkipValidationWhenValueUnchangedDoc: { | ||
typeFilter: simpleTypeFilter, | ||
authorizedRoles: { write: 'write' }, | ||
propertyValidators: { | ||
allowValidationSkip: { | ||
type: 'boolean' | ||
}, | ||
minimumUuidValue: { | ||
type: 'uuid' | ||
}, | ||
uuidProp: { | ||
type: 'uuid', | ||
skipValidationWhenValueUnchanged: function(doc, oldDoc, value, oldValue) { | ||
return !isDocumentMissingOrDeleted(oldDoc) ? oldDoc.allowValidationSkip : doc.allowValidationSkip; | ||
}, | ||
minimumValue: function(doc, oldDoc, value, oldValue) { | ||
return doc.minimumUuidValue; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} |
Oops, something went wrong.