Skip to content

Commit 1577ad2

Browse files
committed
[comments] minor fixes
1 parent e314de2 commit 1577ad2

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

internal/comments/doc.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
//
2121
// List comments for a task:
2222
//
23-
// comments, err := svc.ListByTask(ctx, taskID)
23+
// pagination := &db.Pagination{}
24+
// comments, err := svc.ListByTask(ctx, taskID, pagination)
2425
//
2526
// Update a comment:
2627
//
2728
// update := comments.CommentUpdate{Content: "Updated content"}
28-
// err := svc.Update(ctx, commentID, userID, update)
29+
// err := svc.Update(ctx, userID, commentID, update)
2930
//
3031
// Delete a comment (soft delete):
3132
//
32-
// err := svc.Delete(ctx, commentID, userID)
33+
// err := svc.Delete(ctx, userID, commentID)
3334
package comments

internal/comments/domain.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"strings"
66
"time"
7+
"unicode/utf8"
78

89
"github.com/bit-issues/backend/internal/db"
910
)
@@ -54,7 +55,7 @@ func (i CommentInput) Validate() error {
5455
return fmt.Errorf("%w: content is required", ErrValidationFailed)
5556
}
5657

57-
if len(content) > MaxContentLength {
58+
if utf8.RuneCountInString(content) > MaxContentLength {
5859
return fmt.Errorf("%w: content too long (max %d characters)", ErrValidationFailed, MaxContentLength)
5960
}
6061

@@ -69,7 +70,7 @@ func (u CommentUpdate) Validate() error {
6970
return fmt.Errorf("%w: content is required", ErrValidationFailed)
7071
}
7172

72-
if len(content) > MaxContentLength {
73+
if utf8.RuneCountInString(content) > MaxContentLength {
7374
return fmt.Errorf("%w: content too long (max %d characters)", ErrValidationFailed, MaxContentLength)
7475
}
7576

0 commit comments

Comments
 (0)