Implement helper method for asset reference validation#1086
Open
Toastbrot236 wants to merge 6 commits into
Open
Implement helper method for asset reference validation#1086Toastbrot236 wants to merge 6 commits into
Toastbrot236 wants to merge 6 commits into
Conversation
…ying DataStore when generating DataContext
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a helper method which applies various common validations to a given asset reference (common as in these kinds of validations are needed by various endpoints, like e.g. multiple endpoints needing to ensure a referenced asset is an image, or not a GUID, or not disallowed etc). The idea is that, instead of every endpoint implementing its own validation, they'd just call this method and handle its return value.
This would deduplicate a relatively high amount of code, and it would potentially also prevent edge cases where some endpoints forget to validate some things (e.g. only root level hashes are ensured to be valid hashes right now, some API endpoints only ensure an asset is in the database and not the data store, the photo upload endpoint only ensures a photo's dependencies are in the data store and not the database etc).
Since a complete refactor would've made this PR way larger than it already is (~850 lines just to implement and test the method), this PR only implements and tests the method. Modifying endpoint methods to actually use this method would have to be done in future PRs.