Skip to content

Commit

Permalink
make auto-conversion of string->int more robust to JSON Schema types
Browse files Browse the repository at this point in the history
  • Loading branch information
DocSavage committed Dec 15, 2023
1 parent 9be66ce commit 66c251c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion datatype/neuronjson/neuronjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"math"
"net/http"
reflect "reflect"
"regexp"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -1397,7 +1398,8 @@ func (d *Data) PutData(ctx *datastore.VersionedCtx, keyStr string, value []byte,
}
for err = sch.Validate(v); err != nil; {
if verr, ok := err.(*jsonschema.ValidationError); ok {
if !strings.HasSuffix(verr.Error(), "expected integer, but got string") {
match, _ := regexp.MatchString(`.*expected integer.* but got string.*`, verr.Error())
if !match {
return err
}
// Try to convert string to integer for fields that need conversion.
Expand Down

0 comments on commit 66c251c

Please sign in to comment.