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

Function StringLength

x/errors/validation/string.go:53–69  ·  view source on GitHub ↗

StringLength accepts any string and returns a message if the length is not in the given range.

(min, max int)

Source from the content-addressed store, hash-verified

51
52// StringLength accepts any string and returns a message if the length is not in the given range.
53func StringLength(min, max int) func(s string) string {
54 return func(s string) string {
55 n := len(s)
56
57 if min == max {
58 if n != min {
59 return fmt.Sprintf("must be %d characters", min)
60 }
61 }
62
63 if n < min || n > max {
64 return fmt.Sprintf("must be between %d and %d characters", min, max)
65 }
66
67 return ""
68 }
69}

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…