Skip to content

Implement helper method for asset reference validation#1086

Open
Toastbrot236 wants to merge 6 commits into
LittleBigRefresh:mainfrom
Toastbrot236:res-validation-helper
Open

Implement helper method for asset reference validation#1086
Toastbrot236 wants to merge 6 commits into
LittleBigRefresh:mainfrom
Toastbrot236:res-validation-helper

Conversation

@Toastbrot236
Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant