MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / NotEquals

Function NotEquals

pkg/validation/validation.go:12–29  ·  view source on GitHub ↗

NotEquals requires that the string does not equal any of the specified values

(stringsToCheck []string, errorMessage string)

Source from the content-addressed store, hash-verified

10
11// NotEquals requires that the string does not equal any of the specified values
12func NotEquals(stringsToCheck []string, errorMessage string) survey.Validator {
13 // return a validator to perform the check
14 return func(val interface{}) error {
15 if str, ok := val.(string); ok {
16 for _, v := range stringsToCheck {
17 if str == v {
18 return fmt.Errorf("%s", errorMessage)
19 }
20 }
21 } else {
22 // otherwise we cannot convert the value into a string and cannot perform check
23 return fmt.Errorf("cannot check value on response of type %v", reflect.TypeOf(val).Name())
24 }
25
26 // the input is fine
27 return nil
28 }
29}
30
31// IsUuid requires that the string is a valid UUID
32func IsUuid(val interface{}) error {

Callers 2

PromptMissingFunction · 0.92
TestNotEqualsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestNotEqualsFunction · 0.68