Files
RenewCMS/internal/domain/article/articleDomain.go
T

38 lines
888 B
Go

package article
import (
domain "RenewCMS/internal/domain/image"
"errors"
"time"
"unicode/utf8"
)
var (
ErrInvalidTitle = errors.New("article's title length should be between 3 and 200 caracters")
ErrArticleNotFound = errors.New("article not found")
ErrArticleOffline = errors.New("article is offline")
)
const (
MinTitleRunes = 3
MaxTitleRunes = 200
)
func ValidateTitle(title string) error {
runeCount := utf8.RuneCountInString(title)
if runeCount < MinTitleRunes || runeCount > MaxTitleRunes {
return ErrInvalidTitle
}
return nil
}
type Article struct {
ID uint32 `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
Images []*domain.Image `json:"images"`
IsOnline bool `json:"is_online"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}