Skip to content

Commit

Permalink
Fix #32 (#33)
Browse files Browse the repository at this point in the history
* fix empty rules map that should return an empty json object instead of false

* fix invalid comparisons to nil value #32

Co-authored-by: Ken Polizzi <[email protected]>
  • Loading branch information
fifthaxe and Ken Polizzi authored May 29, 2020
1 parent b679441 commit fa44901
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions comp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ func less(a, b interface{}) bool {
return toNumber(b) > toNumber(a)
}

// comparison to a nil value is falsy
if a == nil || b == nil {
return false
}

return toString(b) > toString(a)
}

Expand All @@ -27,8 +32,15 @@ func equals(a, b interface{}) bool {
if isNumber(a) {
return toNumber(a) == toNumber(b)
}

// comparison to a nil value is falsy
if a == nil || b == nil {
return false
}

if isBool(a) {
return isTrue(a) == isTrue(b)
}

return toString(a) == toString(b)
}

0 comments on commit fa44901

Please sign in to comment.