Our code here has substantial amounts of code duplication, mostly around authenticating user supplied data.
Along the lines of:
Extract element "foo" from the data
Check if element "foo" validates ok
Extract element "bar" from the data
Check if element "bar" validates ok
Extract element "baz" from the data
Check if element "baz" validates ok
(etc)
Instead of that, we should:
Move each of those validation pieces into their own validation function
At the start of each of our handler functions, we have a struct or something that lists each of the user input pieces that need checking, whether it's optional or not, and what validation function should be called for it. Then we call a "DoValidation()" function that checks everything appropriately
I started working on this a few months ago, mainly because it would also get our Unicode handling in place, but got side tracked. It's not even slightly finished, but might be useful as reference info for the next attempt: :wink:
Our code here has substantial amounts of code duplication, mostly around authenticating user supplied data.
Along the lines of:
Instead of that, we should:
We'd likely use https://github.com/go-playground/validator as the base for it.
I started working on this a few months ago, mainly because it would also get our Unicode handling in place, but got side tracked. It's not even slightly finished, but might be useful as reference info for the next attempt: :wink:
https://github.com/sqlitebrowser/dbhub.io/tree/improve_validation_unicode_v1