1
0
mirror of https://github.com/TomWright/dasel.git synced 2022-05-22 02:32:45 +03:00
Files
dasel-data-selector/condition_key_equal.go
Tom Wright 9eb8a5ab6e Search selector (#43)
Implement search selector
2020-11-16 22:44:28 +00:00

23 lines
472 B
Go

package dasel
import (
"reflect"
)
// KeyEqualCondition lets you check for an exact match.
type KeyEqualCondition struct {
// Value is the value we are looking for.
Value string
}
// Check checks to see if other contains the required key value pair.
func (c KeyEqualCondition) Check(other reflect.Value) (bool, error) {
if !other.IsValid() {
return false, &UnhandledCheckType{Value: nil}
}
value := unwrapValue(other)
return c.Value == value.String(), nil
}