Refactor VerificationCode.Validate to separate user error from system error
sethvargo opened this issue · comments
At present, VerificationCode.Validate
returns an error for user error (e.g. invalid symptom onset date) and system error (e.g. code too short).
We need to separate these out because, upstream, it's impossible to determine if we should return a 4xx or 5xx response. Gorm also swallows the concrete error types, so we can't switch on them. However, even if we could, things like checking valid test type already exist in the controller.
/cc @mikehelmick
@whaught for you to consider in your refactor
/assign
We wind up checking most things twice (which is weird) and don't expect .BeforeSave() to fire. The test-too-old for example is checked here for client error:
and then again here:
Yea, I think we should explore moving all of this into the model if possible.