fix(auth,services,profile): add request struct validation
Add validate tags and validators.Validate.Struct() calls on request structs for auth verification, service creation, and user patch test endpoints. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -657,7 +657,7 @@ func GetEligiblePatchTestServicesHandler(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
type AddPatchTestRequest struct {
|
||||
PatchTestID string `json:"patch_test_id"`
|
||||
PatchTestID string `json:"patch_test_id" validate:"required"`
|
||||
}
|
||||
|
||||
// POST /api/admin/users/{id}/patch-tests
|
||||
@@ -674,6 +674,10 @@ func AddPatchTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err := validators.Validate.Struct(&req); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if req.PatchTestID == "" {
|
||||
http.Error(w, "patch_test_id is required", http.StatusBadRequest)
|
||||
|
||||
Reference in New Issue
Block a user