package service import ( "fmt" "strings" "unicode/utf8" "messenger/internal/domain" ) const ( DefaultLimit = 50 MaxLimit = 100 ) func checkText(field, value string, maxRunes int) error { if strings.TrimSpace(value) == "" { return fmt.Errorf("%w: %s must not be empty", domain.ErrInvalidInput, field) } if n := utf8.RuneCountInString(value); n > maxRunes { return fmt.Errorf("%w: %s must be at most %d characters", domain.ErrInvalidInput, field, maxRunes) } return nil } func checkLimit(limit int) error { if limit < 1 || limit > MaxLimit { return fmt.Errorf("%w: limit must be between 1 and %d", domain.ErrInvalidInput, MaxLimit) } return nil }