Skip to content

Commit

Permalink
Support float64 for fuzzyint (#469)
Browse files Browse the repository at this point in the history
* Support float64 for fuzzyInt
  • Loading branch information
DnlLrssn committed Mar 19, 2024
1 parent 1e530d5 commit 38e1236
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions helpers/fuzzyvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type (
// FuzzyBool resolves boolean sent as strings, integers, float64 or boolean, json unmarshal defaults to true
FuzzyBool bool

// FuzzyInt resolves integer sent as string or integer
// FuzzyInt resolves integer sent as string, integer or float64
FuzzyInt int
)

Expand Down Expand Up @@ -96,8 +96,10 @@ func (fi *FuzzyInt) UnmarshalJSON(arg []byte) error {
}
*fi = FuzzyInt(ival)
}
case float64:
*fi = FuzzyInt(val) // Truncate float since should be an integer
default:
return errors.Errorf("Failed to unmarshal value<%v> with type<%T> as integer", arg, val)
return errors.Errorf("Failed to unmarshal value<%v> with type<%T> as integer", val, val)
}
return nil
}

0 comments on commit 38e1236

Please sign in to comment.