Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyCardTranslation = errors.New("card has empty translation")
ErrEmptyCardTranslation is a corresponding error for NotEmptyCardTranslation
View Source
var ErrEmptyCardWord = errors.New("card has empty word")
ErrEmptyCardWord is a corresponding error for NotEmptyCardWord
View Source
var ErrEmptyDeckName = errors.New("deck has empty name")
ErrEmptyDeckName is a corresponding error for NotEmptyDeckName.
View Source
var ErrNotUniqueDeckName = errors.New("deck name is not unique")
ErrNotUniqueDeckName is corrseponding error for UniqueDeckName.
View Source
var NotEmptyCardTranslation = func(card domain.Card) valdy.Checker[domain.Card] { return valdy.NewRule( "card's translation should not be empty", func(card domain.Card) bool { return card.Translation != "" }, ).WithError(ErrEmptyCardTranslation) }
NotEmptyCardTranslation is a rule that checks word's non-emptyness.
View Source
var NotEmptyCardWord = func(card domain.Card) valdy.Checker[domain.Card] { return valdy.NewRule( "card's word should not be empty", func(card domain.Card) bool { return card.Word != "" }, ).WithError(ErrEmptyCardWord) }
NotEmptyCardWord is a rule that checks word's non-emptyness.
View Source
var NotEmptyDeckName = func(deck domain.Deck) valdy.Checker[domain.Deck] { return valdy.NewRule( fmt.Sprintf("deck's(ID=%s) name should not be empty", deck.ID), func(deck domain.Deck) bool { return deck.Name != "" }, ).WithError(ErrEmptyDeckName) }
NotEmptyDeckName is a rule that checks deck's name non-emptyness.
View Source
var UniqueDeckName = func(deckService service.DeckService) valdy.CreateRuleFunc[domain.Deck] { return func(deck domain.Deck) valdy.Checker[domain.Deck] { return valdy.NewRule( fmt.Sprintf("deck name=%s should be unique", deck.Name), func(deck domain.Deck) bool { d, _ := deckService.FindDeckByName(deck.Name) return d == nil }, ).WithError(ErrNotUniqueDeckName) } }
UniqueDeckName is a rule that check deck's name uniqueness.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.