MCPcopy Index your code
hub / github.com/cortexlabs/cortex / validateBoolList

Function validateBoolList

pkg/lib/configreader/bool_list.go:87–116  ·  view source on GitHub ↗
(val []bool, v *BoolListValidation)

Source from the content-addressed store, hash-verified

85}
86
87func validateBoolList(val []bool, v *BoolListValidation) ([]bool, error) {
88 if !v.AllowEmpty {
89 if val != nil && len(val) == 0 {
90 return nil, ErrorCannotBeEmpty()
91 }
92 }
93
94 if v.MinLength != 0 {
95 if len(val) < v.MinLength {
96 return nil, ErrorTooFewElements(v.MinLength)
97 }
98 }
99
100 if v.MaxLength != 0 {
101 if len(val) > v.MaxLength {
102 return nil, ErrorTooManyElements(v.MaxLength)
103 }
104 }
105
106 for _, invalidLength := range v.InvalidLengths {
107 if len(val) == invalidLength {
108 return nil, ErrorWrongNumberOfElements(v.InvalidLengths)
109 }
110 }
111
112 if v.Validator != nil {
113 return v.Validator(val)
114 }
115 return val, nil
116}

Callers 2

ValidateBoolListMissingFunction · 0.85
ValidateBoolListProvidedFunction · 0.85

Calls 4

ErrorCannotBeEmptyFunction · 0.85
ErrorTooFewElementsFunction · 0.85
ErrorTooManyElementsFunction · 0.85

Tested by

no test coverage detected