You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Max starts with "SmallestNonzeroFloat64" which is the smallest positive, non-zero value. So max:[0,0], max:[-1,0], max:[-3,-2] and etc. will all get incorrect answer. Also, min is correctly start with maximum value but min:[] return very large number make no sense. It should return null or error *spec in jsonlogic website return null for empty or if it contains not-numeric-castable.
So I think you should start with first found number. Then compare following number with the first one, not some made-up value. Return null for not-numeric-castable/empty input if want to follow jsonlogic.
The text was updated successfully, but these errors were encountered:
I can provide my current implemented code, though it's not direct PR as I use my "conv.To".
conv.To[float64] is kind of this lib toNumber with return error.
`
func jlMax(values, _ any) any {
v := values.([]any)
if len(v) < 1 {
return nil
}
out, err := conv.To[float64](v[0])
if err != nil {
return nil
}
for i := 1; i < len(v); i++ {
if f, err := conv.To[float64](v[i]); err != nil {
return nil
} else if f > out { //Min is < here
out = f
}
}
return out
Max starts with "SmallestNonzeroFloat64" which is the smallest positive, non-zero value. So max:[0,0], max:[-1,0], max:[-3,-2] and etc. will all get incorrect answer. Also, min is correctly start with maximum value but min:[] return very large number make no sense. It should return null or error *spec in jsonlogic website return null for empty or if it contains not-numeric-castable.
So I think you should start with first found number. Then compare following number with the first one, not some made-up value. Return null for not-numeric-castable/empty input if want to follow jsonlogic.
The text was updated successfully, but these errors were encountered: