Fix validation and data access layer

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-10 15:41:21 +04:00
parent 2cb58d0e32
commit 15c90b2b72
2 changed files with 6 additions and 1 deletions

View File

@@ -127,6 +127,7 @@ func (r *UpdateCookieCategoryRequest) Validate() error {
v.Check(r.CookieCategoryID, "cookie_category_id", validator.Required(), validator.GID(coredata.CookieCategoryEntityType))
v.Check(r.Name, "name", validator.SafeTextNoNewLine(255))
v.Check(r.Description, "description", validator.SafeText(1000))
v.Check(r.Rank, "rank", validator.Min(0))
return v.Error()
}

View File

@@ -338,11 +338,15 @@ WHERE
}
maps.Copy(args, scope.SQLArguments())
_, err := tx.Exec(ctx, q, args)
result, err := tx.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot update cookie banner: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}