Documentation ¶
Index ¶
- Constants
- Variables
- func IsTagsEqual(a, b *Tags) bool
- func ValidateTags(value any) error
- type Pagination
- type PaginationMetadata
- type ReviewInterval
- type Tags
- func (t *Tags) Add(tag string)
- func (t *Tags) AddMany(tags ...string)
- func (t *Tags) AddTags(tags Tags)
- func (t *Tags) Contains(want string) bool
- func (t *Tags) IsEmpty() bool
- func (t *Tags) Normalize()
- func (t *Tags) Remove(tag string)
- func (t *Tags) RemoveMany(tags ...string)
- func (t *Tags) RemoveTags(tags Tags)
- func (t *Tags) String() string
- func (t *Tags) StringArray() []string
- func (t *Tags) TrimSpace() Tags
- func (t *Tags) Unique() Tags
Constants ¶
const ( PaginationDefaultPage = 1 PaginationDefaultPageSize = 10 )
Variables ¶
var ( // ExampleValidTags is an example of valid tags. It is used in tests. ExampleValidTags = NewTags("tag1", "tag2", "tag3") // ExampleInValidTags has more than the maximum number of tags. It is used in tests. ExampleInValidTags = func() Tags { tags := make([]string, maxNumTags+1) for i := 0; i < maxNumTags+1; i++ { tags[i] = gofakeit.LetterN(uint(maxTagLength)) } return NewTags(tags...) } // ExampleInvalidTag is tag with more than the maximum number of characters. It is used in tests. ExampleInvalidTag = gofakeit.LetterN(uint(maxTagLength + 1)) )
---- Tags ----
Functions ¶
func ValidateTags ¶
Types ¶
type Pagination ¶
type Pagination struct {
// contains filtered or unexported fields
}
Pagination is the pagination configuration. Recommended to use `NewPagination` to create a new `Pagination` struct, because it sets default values.
func DefaultPagination ¶
func DefaultPagination() Pagination
func NewPagination ¶
func NewPagination(page, pageSize int) Pagination
NewPagination creates a new `Pagination` struct with default values if none are provided.
func (Pagination) CurrentPage ¶
func (p Pagination) CurrentPage() int
func (Pagination) Limit ¶
func (p Pagination) Limit() int
func (Pagination) Metadata ¶
func (p Pagination) Metadata(totalRecords int) PaginationMetadata
func (Pagination) Offset ¶
func (p Pagination) Offset() int
type PaginationMetadata ¶
type PaginationMetadata struct { CurrentPage int `json:"current_page"` PageSize int `json:"page_size"` FirstPage int `json:"first_page"` LastPage int `json:"last_page"` TotalRecords int `json:"total_records"` }
PaginationMetadata represents the metadata for paginated responses.
func CalculatePaginationMetadata ¶
func CalculatePaginationMetadata(totalRecords, page, pageSize int) PaginationMetadata
CalculatePaginationMetadata calculates the pagination metadata based on the total number of records, the current page, and the page size.
type ReviewInterval ¶
type ReviewInterval struct {
// contains filtered or unexported fields
}
ReviewInterval represents the interval of time between reviews.
func DefaultReviewIntervals ¶
func DefaultReviewIntervals() ReviewInterval
func ParseReviewInterval ¶
func ParseReviewInterval(interval string) (ReviewInterval, error)
ParseReviewInterval parses the review interval from a string separated by spaces.
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags represents a list of tags encapsulated in a struct.
func NewTags ¶
NewTags creates a new Tags object with the given tags.
NOTE: If the tags array is empty or nil, it will return nil.
func (*Tags) Add ¶
Add adds a new tag to the list. If the tag already exists, it will not be added again. The tag will be trimmed before adding it to the list.
func (*Tags) AddMany ¶
AddMany adds multiple tags to the list. If a tag already exists, it will not be added again.
func (*Tags) Normalize ¶
func (t *Tags) Normalize()
Normalize trims spaces and removes duplicate tags from the list.
func (*Tags) Remove ¶
Remove removes a tag from the list. If the tag does not exist, it will not be removed.
func (*Tags) RemoveMany ¶
RemoveMany removes multiple tags from the list.
func (*Tags) RemoveTags ¶
RemoveTags removes multiple tags from the list.