github.com/blend/go-sdk@v1.20220411.3/selector/not_equals.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package selector 9 10 import "fmt" 11 12 // NotEquals returns if a key strictly equals a value. 13 type NotEquals struct { 14 Key, Value string 15 } 16 17 // Matches returns the selector result. 18 func (ne NotEquals) Matches(labels Labels) bool { 19 if value, hasValue := labels[ne.Key]; hasValue { 20 return ne.Value != value 21 } 22 return true 23 } 24 25 // Validate validates the selector. 26 func (ne NotEquals) Validate() (err error) { 27 err = CheckKey(ne.Key) 28 if err != nil { 29 return 30 } 31 err = CheckValue(ne.Value) 32 return 33 } 34 35 // String returns a string representation of the selector. 36 func (ne NotEquals) String() string { 37 return fmt.Sprintf("%s != %s", ne.Key, ne.Value) 38 }