Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmossas committed Nov 10, 2024
1 parent 7312a69 commit a067d61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions languages/go/go-server/decode_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestDecodeObjectWithOptionalFields(t *testing.T) {
return
}
if !reflect.DeepEqual(noUndefinedTarget, noUndefinedExpectedResult) {
t.Errorf("\n%+v\ndoes not equal\n%+v", noUndefinedTarget, noUndefinedExpectedResult)
t.Errorf(deepEqualErrString(noUndefinedTarget, noUndefinedExpectedResult))
return
}
allUndefinedInput, allUndefinedInputErr := os.ReadFile("../../../tests/test-files/ObjectWithOptionalFields_AllUndefined.json")
Expand All @@ -119,7 +119,7 @@ func TestDecodeObjectWithOptionalFields(t *testing.T) {
return
}
if !reflect.DeepEqual(allUndefinedTarget, allUndefinedExpectedResult) {
t.Errorf("\n%+v\ndoes not equal\n%+v", allUndefinedTarget, allUndefinedExpectedResult)
t.Errorf(deepEqualErrString(allUndefinedTarget, allUndefinedExpectedResult))
return
}
}
Expand Down
22 changes: 12 additions & 10 deletions languages/go/go-server/type_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/json"
"fmt"
"reflect"

"github.com/tidwall/gjson"
)

type DiscriminatorKey struct{}
Expand Down Expand Up @@ -69,14 +67,18 @@ func (s Option[T]) String() string {
}
}

func (s Option[T]) DecodeJSON(data *gjson.Result, target reflect.Value, context *ValidationContext) bool {
if data.Type != gjson.JSON {
err := newValidationErrorItem("expected object got", context.InstancePath, context.SchemaPath)
*context.Errors = append(*context.Errors, err)
return false
}
return false
}
// func (s Option[T]) DecodeJSON(data *gjson.Result, target reflect.Value, context *ValidationContext) bool {
// fmt.Println("DECODING JSON")
// if !data.Exists() || data.Type == gjson.Null {
// return true
// }
// ok := typeFromJSON(data, target.Field(0), context)
// if ok {
// target.Field(1).SetBool(true)
// return true
// }
// return false
// }

//// Nullable Types ////

Expand Down

0 comments on commit a067d61

Please sign in to comment.