feat(app) lab2 prepared for mr

This commit is contained in:
imadev
2026-10-23 18:55:20 +03:00
parent 1db3953226
commit f6e74247fd
57 changed files with 2367 additions and 660 deletions
+13 -2
View File
@@ -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"