fix: Code for category

This commit is contained in:
2026-06-27 19:35:53 +05:00
parent 46add88fd5
commit 148d1fb841
14 changed files with 127 additions and 64 deletions

View File

@@ -1,6 +1,7 @@
package domain
import (
"regexp"
"time"
"github.com/google/uuid"
@@ -11,8 +12,19 @@ import (
type Category struct {
ID uuid.UUID `json:"id"`
ParentID *uuid.UUID `json:"parent_id"`
Code string `json:"code"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// slugPattern matches a slug: lowercase latin letters and digits in
// dash-separated groups, e.g. "population", "land-use-2024".
var slugPattern = regexp.MustCompile(`^[a-z0-9]+(?:-[a-z0-9]+)*$`)
// ValidSlug reports whether s is a valid slug (lowercase latin letters, digits,
// and single dashes between groups; no leading, trailing, or repeated dashes).
func ValidSlug(s string) bool {
return slugPattern.MatchString(s)
}