MCPcopy Create free account
hub / github.com/kataras/iris / SliceLength

Function SliceLength

x/errors/validation/slice.go:40–58  ·  view source on GitHub ↗

SliceLength accepts any slice and returns a message if the length is not in the given range.

(min, max int)

Source from the content-addressed store, hash-verified

38
39// SliceLength accepts any slice and returns a message if the length is not in the given range.
40func SliceLength[T any, V SliceType[T]](min, max int) func(s V) string {
41 return func(s V) string {
42 n := len(s)
43
44 if min == max {
45 if n != min {
46 return fmt.Sprintf("must be %d elements", min)
47 }
48
49 return ""
50 }
51
52 if n < min || n > max {
53 return fmt.Sprintf("must be between %d and %d elements", min, max)
54 }
55
56 return ""
57 }
58}

Callers 1

LengthMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…