forked from mtusi2026/mtusi2026lab3
feat(app) lab 3 implemented
This commit is contained in:
@@ -9,15 +9,6 @@ import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// AGENT: Field-level validation is deliberately not delegated to a generic
|
||||
// struct validator. The contract needs specific messages for blank strings,
|
||||
// Unicode length and duplicate member IDs, so handlers call the Validators in
|
||||
// validation.go after this strict JSON decoding step.
|
||||
//
|
||||
// BindJSON enforces the request format from the contract: JSON content type,
|
||||
// exactly one JSON value, no unknown fields and correct Go types. Field-level
|
||||
// rules (non-blank strings, lengths, UUID lists) stay in the handlers so their
|
||||
// messages can be specific.
|
||||
func BindJSON(c fiber.Ctx, dst any) error {
|
||||
if contentType := c.Get(fiber.HeaderContentType); !strings.HasPrefix(contentType, "application/json") {
|
||||
return UnsupportedMedia("invalid JSON body")
|
||||
|
||||
Reference in New Issue
Block a user