Skip to content

Commit

Permalink
support Is combinator for constrains
Browse files Browse the repository at this point in the history
  • Loading branch information
fogfish committed Nov 30, 2020
1 parent 580b7c3 commit 6467d59
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions constrain.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ func (e ElemIs) Ge(val interface{}) Config {
return e.compare(">=", val)
}

/*
Is matches either Eq or NotExists if value is not defined
*/
func (e ElemIs) Is(val string) Config {
if val == "_" {
return e.NotExists()
}

return e.Eq(val)
}

func (e ElemIs) compare(fn string, val interface{}) Config {
return func(
conditionExpression **string,
Expand Down

0 comments on commit 6467d59

Please sign in to comment.