README
¶
Combination
combination 包提供了一些实用的组合函数。
目录导航
列出了该 package
下所有的函数及类型定义,可通过目录导航进行快捷跳转 ❤️
展开 / 折叠目录导航
包级函数定义
类型定义
类型 | 名称 | 描述 |
---|---|---|
STRUCT |
Combination | 用于从多个匹配器内提取组合的数据结构 |
STRUCT |
Option | 组合器选项 |
INTERFACE |
Item | 暂无描述... |
STRUCT |
Matcher | 用于从一组数据内提取组合的数据结构 |
STRUCT |
MatcherOption | 匹配器选项 |
STRUCT |
Validator | 用于对组合进行验证的校验器 |
STRUCT |
ValidatorOption | 暂无描述... |
详情信息
func NewCombination[T Item](options ...Option[T]) *Combination[T]
创建一个新的组合器
func WithEvaluation[T Item](evaluate func (items []T) float64) Option[T]
设置组合评估函数
- 用于对组合进行评估,返回一个分值的评价函数
- 通过该选项将设置所有匹配器的默认评估函数为该函数
- 通过匹配器选项 WithMatcherEvaluation 可以覆盖该默认评估函数
- 默认的评估函数将返回一个随机数
func NewMatcher[T Item](options ...MatcherOption[T]) *Matcher[T]
创建一个新的匹配器
func WithMatcherEvaluation[T Item](evaluate func (items []T) float64) MatcherOption[T]
设置匹配器评估函数
- 用于对组合进行评估,返回一个分值的评价函数
- 通过该选项将覆盖匹配器的默认(WithEvaluation)评估函数
func WithMatcherLeastLength[T Item](length int) MatcherOption[T]
通过匹配最小长度的组合创建匹配器
- length: 组合的长度,表示需要匹配的组合最小数量
func WithMatcherLength[T Item](length int) MatcherOption[T]
通过匹配长度的组合创建匹配器
- length: 组合的长度,表示需要匹配的组合数量
func WithMatcherMostLength[T Item](length int) MatcherOption[T]
通过匹配最大长度的组合创建匹配器
- length: 组合的长度,表示需要匹配的组合最大数量
func WithMatcherIntervalLength[T Item](min int, max int) MatcherOption[T]
通过匹配长度区间的组合创建匹配器
- min: 组合的最小长度,表示需要匹配的组合最小数量
- max: 组合的最大长度,表示需要匹配的组合最大数量
func WithMatcherContinuity[T Item, Index generic.Number](getIndex func (item T) Index) MatcherOption[T]
通过匹配连续的组合创建匹配器
- index: 用于获取组合中元素的索引值,用于判断是否连续
func WithMatcherSame[T Item, E generic.Ordered](count int, getType func (item T) E) MatcherOption[T]
通过匹配相同的组合创建匹配器
- count: 组合中相同元素的数量,当 count <= 0 时,表示相同元素的数量不限
- getType: 用于获取组合中元素的类型,用于判断是否相同
func WithMatcherNCarryM[T Item, E generic.Ordered](n int, m int, getType func (item T) E) MatcherOption[T]
通过匹配 N 携带 M 的组合创建匹配器
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型需要全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
func WithMatcherNCarryIndependentM[T Item, E generic.Ordered](n int, m int, getType func (item T) E) MatcherOption[T]
通过匹配 N 携带独立 M 的组合创建匹配器
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型无需全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
func NewValidator[T Item](options ...ValidatorOption[T]) *Validator[T]
创建一个新的校验器
func WithValidatorHandle[T Item](handle func (items []T) bool) ValidatorOption[T]
通过特定的验证函数对组合进行验证
func WithValidatorHandleLength[T Item](length int) ValidatorOption[T]
校验组合的长度是否符合要求
func WithValidatorHandleLengthRange[T Item](min int, max int) ValidatorOption[T]
校验组合的长度是否在指定的范围内
func WithValidatorHandleLengthMin[T Item](min int) ValidatorOption[T]
校验组合的长度是否大于等于指定的最小值
func WithValidatorHandleLengthMax[T Item](max int) ValidatorOption[T]
校验组合的长度是否小于等于指定的最大值
func WithValidatorHandleLengthNot[T Item](length int) ValidatorOption[T]
校验组合的长度是否不等于指定的值
func WithValidatorHandleTypeLength[T Item, E generic.Ordered](length int, getType func (item T) E) ValidatorOption[T]
校验组合成员类型数量是否为指定的值
func WithValidatorHandleTypeLengthRange[T Item, E generic.Ordered](min int, max int, getType func (item T) E) ValidatorOption[T]
校验组合成员类型数量是否在指定的范围内
func WithValidatorHandleTypeLengthMin[T Item, E generic.Ordered](min int, getType func (item T) E) ValidatorOption[T]
校验组合成员类型数量是否大于等于指定的最小值
func WithValidatorHandleTypeLengthMax[T Item, E generic.Ordered](max int, getType func (item T) E) ValidatorOption[T]
校验组合成员类型数量是否小于等于指定的最大值
func WithValidatorHandleTypeLengthNot[T Item, E generic.Ordered](length int, getType func (item T) E) ValidatorOption[T]
校验组合成员类型数量是否不等于指定的值
func WithValidatorHandleContinuous[T Item, Index generic.Integer](getIndex func (item T) Index) ValidatorOption[T]
校验组合成员是否连续
func WithValidatorHandleContinuousNot[T Item, Index generic.Integer](getIndex func (item T) Index) ValidatorOption[T]
校验组合成员是否不连续
func WithValidatorHandleGroupContinuous[T Item, E generic.Ordered, Index generic.Integer](getType func (item T) E, getIndex func (item T) Index) ValidatorOption[T]
校验组合成员是否能够按类型分组并且连续
func WithValidatorHandleGroupContinuousN[T Item, E generic.Ordered, Index generic.Integer](n int, getType func (item T) E, getIndex func (item T) Index) ValidatorOption[T]
校验组合成员是否能够按分组为 n 组类型并且连续
func WithValidatorHandleNCarryM[T Item, E generic.Ordered](n int, m int, getType func (item T) E) ValidatorOption[T]
校验组合成员是否匹配 N 携带相同的 M 的组合
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型需要全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
func WithValidatorHandleNCarryIndependentM[T Item, E generic.Ordered](n int, m int, getType func (item T) E) ValidatorOption[T]
校验组合成员是否匹配 N 携带独立的 M 的组合
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型无需全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
Combination STRUCT
用于从多个匹配器内提取组合的数据结构
type Combination[T Item] struct {
evaluate func([]T) float64
matchers map[string]*Matcher[T]
priority []string
}
func (*Combination) NewMatcher(name string, options ...MatcherOption[T]) *Combination[T]
添加一个新的匹配器
func (*Combination) AddMatcher(name string, matcher *Matcher[T]) *Combination[T]
添加一个匹配器
func (*Combination) RemoveMatcher(name string) *Combination[T]
移除一个匹配器
func (*Combination) Combinations(items []T) (result [][]T)
从一组数据中提取所有符合匹配器规则的组合
func (*Combination) CombinationsToName(items []T) (result map[string][][]T)
从一组数据中提取所有符合匹配器规则的组合,并返回匹配器名称
func (*Combination) Best(items []T) (name string, result []T)
从一组数据中提取符合匹配器规则的最佳组合
查看 / 收起单元测试
func TestCombination_Best(t *testing.T) {
combine := combination.NewCombination(combination.WithEvaluation(func(items []*Poker) float64 {
var total float64
for _, item := range items {
total += float64(item.Point)
}
return total
}))
combine.NewMatcher("炸弹", combination.WithMatcherSame[*Poker, int](4, func(item *Poker) int {
return item.Point
})).NewMatcher("三带一", combination.WithMatcherNCarryM[*Poker, int](3, 1, func(item *Poker) int {
return item.Point
}))
var cards = []*Poker{{Point: 2, Color: 1}, {Point: 2, Color: 2}, {Point: 2, Color: 3}, {Point: 3, Color: 4}, {Point: 4, Color: 1}, {Point: 4, Color: 2}, {Point: 5, Color: 3}, {Point: 6, Color: 4}, {Point: 7, Color: 1}, {Point: 8, Color: 2}, {Point: 9, Color: 3}, {Point: 10, Color: 4}, {Point: 11, Color: 1}, {Point: 12, Color: 2}, {Point: 13, Color: 3}, {Point: 10, Color: 3}, {Point: 11, Color: 2}, {Point: 12, Color: 1}, {Point: 13, Color: 4}, {Point: 10, Color: 2}}
name, result := combine.Worst(cards)
fmt.Println("best:", name)
for _, item := range result {
fmt.Println(item)
}
}
func (*Combination) Worst(items []T) (name string, result []T)
从一组数据中提取符合匹配器规则的最差组合
Option STRUCT
组合器选项
type Option[T Item] func(*Combination[T])
Item INTERFACE
type Item interface{}
Matcher STRUCT
用于从一组数据内提取组合的数据结构
type Matcher[T Item] struct {
evaluate func(items []T) float64
filter []func(items []T) [][]T
}
func (*Matcher) AddFilter(filter func (items []T) [][]T)
添加一个筛选器
- 筛选器用于对组合进行筛选,返回一个二维数组,每个数组内的元素都是一个组合
func (*Matcher) Combinations(items []T) [][]T
从一组数据中提取所有符合筛选器规则的组合
func (*Matcher) Best(items []T) []T
从一组数据中提取符筛选器规则的最佳组合
func (*Matcher) Worst(items []T) []T
从一组数据中提取符筛选器规则的最差组合
MatcherOption STRUCT
匹配器选项
type MatcherOption[T Item] func(matcher *Matcher[T])
Validator STRUCT
用于对组合进行验证的校验器
type Validator[T Item] struct {
vh []func(items []T) bool
}
func (*Validator) Validate(items []T) bool
校验组合是否符合要求
查看 / 收起单元测试
func TestValidator_Validate(t *testing.T) {
v := combination.NewValidator[*Card](combination.WithValidatorHandleContinuous[*Card, int](func(item *Card) int {
switch item.Point {
case "A":
return 1
case "2", "3", "4", "5", "6", "7", "8", "9", "10":
return super.StringToInt(item.Point)
case "J":
return 11
case "Q":
return 12
case "K":
return 13
}
return -1
}), combination.WithValidatorHandleLength[*Card](3))
cards := []*Card{{Point: "2", Color: "Spade"}, {Point: "4", Color: "Heart"}, {Point: "3", Color: "Diamond"}}
fmt.Println(v.Validate(cards))
}
ValidatorOption STRUCT
type ValidatorOption[T Item] func(validator *Validator[T])
Documentation
¶
Overview ¶
Package combination 包提供了一些实用的组合函数。
Index ¶
- type Combination
- func (slf *Combination[T]) AddMatcher(name string, matcher *Matcher[T]) *Combination[T]
- func (slf *Combination[T]) Best(items []T) (name string, result []T)
- func (slf *Combination[T]) Combinations(items []T) (result [][]T)
- func (slf *Combination[T]) CombinationsToName(items []T) (result map[string][][]T)
- func (slf *Combination[T]) NewMatcher(name string, options ...MatcherOption[T]) *Combination[T]
- func (slf *Combination[T]) RemoveMatcher(name string) *Combination[T]
- func (slf *Combination[T]) Worst(items []T) (name string, result []T)
- type Item
- type Matcher
- type MatcherOption
- func WithMatcherContinuity[T Item, Index generic.Number](getIndex func(item T) Index) MatcherOption[T]
- func WithMatcherEvaluation[T Item](evaluate func(items []T) float64) MatcherOption[T]
- func WithMatcherIntervalLength[T Item](min, max int) MatcherOption[T]
- func WithMatcherLeastLength[T Item](length int) MatcherOption[T]
- func WithMatcherLength[T Item](length int) MatcherOption[T]
- func WithMatcherMostLength[T Item](length int) MatcherOption[T]
- func WithMatcherNCarryIndependentM[T Item, E generic.Ordered](n, m int, getType func(item T) E) MatcherOption[T]
- func WithMatcherNCarryM[T Item, E generic.Ordered](n, m int, getType func(item T) E) MatcherOption[T]
- func WithMatcherSame[T Item, E generic.Ordered](count int, getType func(item T) E) MatcherOption[T]
- type Option
- type Validator
- type ValidatorOption
- func WithValidatorHandle[T Item](handle func(items []T) bool) ValidatorOption[T]
- func WithValidatorHandleContinuous[T Item, Index generic.Integer](getIndex func(item T) Index) ValidatorOption[T]
- func WithValidatorHandleContinuousNot[T Item, Index generic.Integer](getIndex func(item T) Index) ValidatorOption[T]
- func WithValidatorHandleGroupContinuous[T Item, E generic.Ordered, Index generic.Integer](getType func(item T) E, getIndex func(item T) Index) ValidatorOption[T]
- func WithValidatorHandleGroupContinuousN[T Item, E generic.Ordered, Index generic.Integer](n int, getType func(item T) E, getIndex func(item T) Index) ValidatorOption[T]
- func WithValidatorHandleLength[T Item](length int) ValidatorOption[T]
- func WithValidatorHandleLengthMax[T Item](max int) ValidatorOption[T]
- func WithValidatorHandleLengthMin[T Item](min int) ValidatorOption[T]
- func WithValidatorHandleLengthNot[T Item](length int) ValidatorOption[T]
- func WithValidatorHandleLengthRange[T Item](min, max int) ValidatorOption[T]
- func WithValidatorHandleNCarryIndependentM[T Item, E generic.Ordered](n, m int, getType func(item T) E) ValidatorOption[T]
- func WithValidatorHandleNCarryM[T Item, E generic.Ordered](n, m int, getType func(item T) E) ValidatorOption[T]
- func WithValidatorHandleTypeLength[T Item, E generic.Ordered](length int, getType func(item T) E) ValidatorOption[T]
- func WithValidatorHandleTypeLengthMax[T Item, E generic.Ordered](max int, getType func(item T) E) ValidatorOption[T]
- func WithValidatorHandleTypeLengthMin[T Item, E generic.Ordered](min int, getType func(item T) E) ValidatorOption[T]
- func WithValidatorHandleTypeLengthNot[T Item, E generic.Ordered](length int, getType func(item T) E) ValidatorOption[T]
- func WithValidatorHandleTypeLengthRange[T Item, E generic.Ordered](min, max int, getType func(item T) E) ValidatorOption[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Combination ¶
type Combination[T Item] struct { // contains filtered or unexported fields }
Combination 用于从多个匹配器内提取组合的数据结构
func NewCombination ¶
func NewCombination[T Item](options ...Option[T]) *Combination[T]
NewCombination 创建一个新的组合器
func (*Combination[T]) AddMatcher ¶
func (slf *Combination[T]) AddMatcher(name string, matcher *Matcher[T]) *Combination[T]
AddMatcher 添加一个匹配器
func (*Combination[T]) Best ¶
func (slf *Combination[T]) Best(items []T) (name string, result []T)
Best 从一组数据中提取符合匹配器规则的最佳组合
func (*Combination[T]) Combinations ¶
func (slf *Combination[T]) Combinations(items []T) (result [][]T)
Combinations 从一组数据中提取所有符合匹配器规则的组合
func (*Combination[T]) CombinationsToName ¶
func (slf *Combination[T]) CombinationsToName(items []T) (result map[string][][]T)
CombinationsToName 从一组数据中提取所有符合匹配器规则的组合,并返回匹配器名称
func (*Combination[T]) NewMatcher ¶
func (slf *Combination[T]) NewMatcher(name string, options ...MatcherOption[T]) *Combination[T]
NewMatcher 添加一个新的匹配器
func (*Combination[T]) RemoveMatcher ¶
func (slf *Combination[T]) RemoveMatcher(name string) *Combination[T]
RemoveMatcher 移除一个匹配器
func (*Combination[T]) Worst ¶
func (slf *Combination[T]) Worst(items []T) (name string, result []T)
Worst 从一组数据中提取符合匹配器规则的最差组合
type Matcher ¶
type Matcher[T Item] struct { // contains filtered or unexported fields }
Matcher 用于从一组数据内提取组合的数据结构
func NewMatcher ¶
func NewMatcher[T Item](options ...MatcherOption[T]) *Matcher[T]
NewMatcher 创建一个新的匹配器
func (*Matcher[T]) AddFilter ¶
func (slf *Matcher[T]) AddFilter(filter func(items []T) [][]T)
AddFilter 添加一个筛选器
- 筛选器用于对组合进行筛选,返回一个二维数组,每个数组内的元素都是一个组合
func (*Matcher[T]) Combinations ¶
func (slf *Matcher[T]) Combinations(items []T) [][]T
Combinations 从一组数据中提取所有符合筛选器规则的组合
type MatcherOption ¶
MatcherOption 匹配器选项
func WithMatcherContinuity ¶
func WithMatcherContinuity[T Item, Index generic.Number](getIndex func(item T) Index) MatcherOption[T]
WithMatcherContinuity 通过匹配连续的组合创建匹配器
- index: 用于获取组合中元素的索引值,用于判断是否连续
func WithMatcherEvaluation ¶
func WithMatcherEvaluation[T Item](evaluate func(items []T) float64) MatcherOption[T]
WithMatcherEvaluation 设置匹配器评估函数
- 用于对组合进行评估,返回一个分值的评价函数
- 通过该选项将覆盖匹配器的默认(WithEvaluation)评估函数
func WithMatcherIntervalLength ¶
func WithMatcherIntervalLength[T Item](min, max int) MatcherOption[T]
WithMatcherIntervalLength 通过匹配长度区间的组合创建匹配器
- min: 组合的最小长度,表示需要匹配的组合最小数量
- max: 组合的最大长度,表示需要匹配的组合最大数量
func WithMatcherLeastLength ¶
func WithMatcherLeastLength[T Item](length int) MatcherOption[T]
WithMatcherLeastLength 通过匹配最小长度的组合创建匹配器
- length: 组合的长度,表示需要匹配的组合最小数量
func WithMatcherLength ¶
func WithMatcherLength[T Item](length int) MatcherOption[T]
WithMatcherLength 通过匹配长度的组合创建匹配器
- length: 组合的长度,表示需要匹配的组合数量
func WithMatcherMostLength ¶
func WithMatcherMostLength[T Item](length int) MatcherOption[T]
WithMatcherMostLength 通过匹配最大长度的组合创建匹配器
- length: 组合的长度,表示需要匹配的组合最大数量
func WithMatcherNCarryIndependentM ¶
func WithMatcherNCarryIndependentM[T Item, E generic.Ordered](n, m int, getType func(item T) E) MatcherOption[T]
WithMatcherNCarryIndependentM 通过匹配 N 携带独立 M 的组合创建匹配器
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型无需全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
func WithMatcherNCarryM ¶
func WithMatcherNCarryM[T Item, E generic.Ordered](n, m int, getType func(item T) E) MatcherOption[T]
WithMatcherNCarryM 通过匹配 N 携带 M 的组合创建匹配器
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型需要全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
func WithMatcherSame ¶
func WithMatcherSame[T Item, E generic.Ordered](count int, getType func(item T) E) MatcherOption[T]
WithMatcherSame 通过匹配相同的组合创建匹配器
- count: 组合中相同元素的数量,当 count <= 0 时,表示相同元素的数量不限
- getType: 用于获取组合中元素的类型,用于判断是否相同
type Option ¶
type Option[T Item] func(*Combination[T])
Option 组合器选项
func WithEvaluation ¶
WithEvaluation 设置组合评估函数
- 用于对组合进行评估,返回一个分值的评价函数
- 通过该选项将设置所有匹配器的默认评估函数为该函数
- 通过匹配器选项 WithMatcherEvaluation 可以覆盖该默认评估函数
- 默认的评估函数将返回一个随机数
type Validator ¶ added in v0.0.25
type Validator[T Item] struct { // contains filtered or unexported fields }
Validator 用于对组合进行验证的校验器
func NewValidator ¶ added in v0.0.25
func NewValidator[T Item](options ...ValidatorOption[T]) *Validator[T]
NewValidator 创建一个新的校验器
type ValidatorOption ¶ added in v0.0.25
func WithValidatorHandle ¶ added in v0.0.25
func WithValidatorHandle[T Item](handle func(items []T) bool) ValidatorOption[T]
WithValidatorHandle 通过特定的验证函数对组合进行验证
func WithValidatorHandleContinuous ¶ added in v0.0.25
func WithValidatorHandleContinuous[T Item, Index generic.Integer](getIndex func(item T) Index) ValidatorOption[T]
WithValidatorHandleContinuous 校验组合成员是否连续
func WithValidatorHandleContinuousNot ¶ added in v0.0.25
func WithValidatorHandleContinuousNot[T Item, Index generic.Integer](getIndex func(item T) Index) ValidatorOption[T]
WithValidatorHandleContinuousNot 校验组合成员是否不连续
func WithValidatorHandleGroupContinuous ¶ added in v0.0.25
func WithValidatorHandleGroupContinuous[T Item, E generic.Ordered, Index generic.Integer](getType func(item T) E, getIndex func(item T) Index) ValidatorOption[T]
WithValidatorHandleGroupContinuous 校验组合成员是否能够按类型分组并且连续
func WithValidatorHandleGroupContinuousN ¶ added in v0.0.25
func WithValidatorHandleGroupContinuousN[T Item, E generic.Ordered, Index generic.Integer](n int, getType func(item T) E, getIndex func(item T) Index) ValidatorOption[T]
WithValidatorHandleGroupContinuousN 校验组合成员是否能够按分组为 n 组类型并且连续
func WithValidatorHandleLength ¶ added in v0.0.25
func WithValidatorHandleLength[T Item](length int) ValidatorOption[T]
WithValidatorHandleLength 校验组合的长度是否符合要求
func WithValidatorHandleLengthMax ¶ added in v0.0.25
func WithValidatorHandleLengthMax[T Item](max int) ValidatorOption[T]
WithValidatorHandleLengthMax 校验组合的长度是否小于等于指定的最大值
func WithValidatorHandleLengthMin ¶ added in v0.0.25
func WithValidatorHandleLengthMin[T Item](min int) ValidatorOption[T]
WithValidatorHandleLengthMin 校验组合的长度是否大于等于指定的最小值
func WithValidatorHandleLengthNot ¶ added in v0.0.25
func WithValidatorHandleLengthNot[T Item](length int) ValidatorOption[T]
WithValidatorHandleLengthNot 校验组合的长度是否不等于指定的值
func WithValidatorHandleLengthRange ¶ added in v0.0.25
func WithValidatorHandleLengthRange[T Item](min, max int) ValidatorOption[T]
WithValidatorHandleLengthRange 校验组合的长度是否在指定的范围内
func WithValidatorHandleNCarryIndependentM ¶ added in v0.0.25
func WithValidatorHandleNCarryIndependentM[T Item, E generic.Ordered](n, m int, getType func(item T) E) ValidatorOption[T]
WithValidatorHandleNCarryIndependentM 校验组合成员是否匹配 N 携带独立的 M 的组合
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型无需全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
func WithValidatorHandleNCarryM ¶ added in v0.0.25
func WithValidatorHandleNCarryM[T Item, E generic.Ordered](n, m int, getType func(item T) E) ValidatorOption[T]
WithValidatorHandleNCarryM 校验组合成员是否匹配 N 携带相同的 M 的组合
- n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同
- m: 组合中元素的数量,表示需要匹配的组合数量,m 的类型需要全部相同
- getType: 用于获取组合中元素的类型,用于判断是否相同
func WithValidatorHandleTypeLength ¶ added in v0.0.25
func WithValidatorHandleTypeLength[T Item, E generic.Ordered](length int, getType func(item T) E) ValidatorOption[T]
WithValidatorHandleTypeLength 校验组合成员类型数量是否为指定的值
func WithValidatorHandleTypeLengthMax ¶ added in v0.0.25
func WithValidatorHandleTypeLengthMax[T Item, E generic.Ordered](max int, getType func(item T) E) ValidatorOption[T]
WithValidatorHandleTypeLengthMax 校验组合成员类型数量是否小于等于指定的最大值
func WithValidatorHandleTypeLengthMin ¶ added in v0.0.25
func WithValidatorHandleTypeLengthMin[T Item, E generic.Ordered](min int, getType func(item T) E) ValidatorOption[T]
WithValidatorHandleTypeLengthMin 校验组合成员类型数量是否大于等于指定的最小值
func WithValidatorHandleTypeLengthNot ¶ added in v0.0.25
func WithValidatorHandleTypeLengthNot[T Item, E generic.Ordered](length int, getType func(item T) E) ValidatorOption[T]
WithValidatorHandleTypeLengthNot 校验组合成员类型数量是否不等于指定的值
func WithValidatorHandleTypeLengthRange ¶ added in v0.0.25
func WithValidatorHandleTypeLengthRange[T Item, E generic.Ordered](min, max int, getType func(item T) E) ValidatorOption[T]
WithValidatorHandleTypeLengthRange 校验组合成员类型数量是否在指定的范围内