Skip to content

Commit

Permalink
feat: change response for Evaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanarya0 committed Mar 6, 2024
1 parent 443c796 commit 070cd51
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ type Comparison struct {
Value any `yaml:"value" mapstructure:"value"`
}

func (e Expression) Evaluate() (any, error) {
func (e Expression) Evaluate() (bool, error) {
if !reflect.ValueOf(e.Comparison).IsZero() {
var output any
output := false
var err error
switch e.Comparison.Operator {
case "==":
output = reflect.DeepEqual(e.Comparison.Key, e.Comparison.Value)
err = nil
default:
err = errors.New(fmt.Sprintf("unsupported comparison operator %s", e.Comparison.Operator))
output = nil
}

return output, err
}
return nil, errors.New("no supported operators configured")
return false, errors.New("no supported operators configured")
}

func (e Expression) IsEmpty() bool {
Expand Down

0 comments on commit 070cd51

Please sign in to comment.