forked from mtusi2026/mtusi2026lab2
feat(app) lab2 prepared for mr
This commit is contained in:
@@ -34,7 +34,7 @@ func BindJSON(c fiber.Ctx, req any) error {
|
||||
decoder.DisallowUnknownFields()
|
||||
|
||||
if err := decoder.Decode(req); err != nil {
|
||||
return BadRequest(err.Error())
|
||||
return BadRequest("invalid JSON body")
|
||||
}
|
||||
|
||||
var extra json.RawMessage
|
||||
@@ -43,7 +43,7 @@ func BindJSON(c fiber.Ctx, req any) error {
|
||||
}
|
||||
|
||||
if err := validate.Struct(req); err != nil {
|
||||
return BadRequest("field validation failed: " + err.Error())
|
||||
return BadRequest("field validation failed")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -74,6 +74,17 @@ func ValidateCreateUser(username, displayName string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// ValidatePassword enforces the contract range in Unicode code points. The
|
||||
// upper bound matters: bcrypt would silently truncate, which is why this
|
||||
// project uses Argon2id instead.
|
||||
func ValidatePassword(password string) string {
|
||||
if !strLenBetween(password, 12, 128) {
|
||||
return "password must be between 12 and 128 Unicode code points"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func ValidateChatTitle(title string) string {
|
||||
if blank(title) {
|
||||
return "title must not be empty or only whitespace"
|
||||
|
||||
Reference in New Issue
Block a user