MCPcopy Create free account
hub / github.com/cli/cli / ValidateValue

Function ValidateValue

pkg/cmd/config/set/set.go:109–128  ·  view source on GitHub ↗
(key, value string)

Source from the content-addressed store, hash-verified

107}
108
109func ValidateValue(key, value string) error {
110 var validValues []string
111
112 for _, v := range config.Options {
113 if v.Key == key {
114 validValues = v.AllowedValues
115 break
116 }
117 }
118
119 if validValues == nil {
120 return nil
121 }
122
123 if slices.Contains(validValues, value) {
124 return nil
125 }
126
127 return InvalidValueError{ValidValues: validValues}
128}

Callers 2

setRunFunction · 0.85
Test_ValidateValueFunction · 0.85

Calls 1

ContainsMethod · 0.80

Tested by 1

Test_ValidateValueFunction · 0.68