Skip to content

Commit

Permalink
fix: null as empty
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Feb 3, 2025
1 parent f17cb42 commit 059bbf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pkg/validator/internal/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package internal
import (
"cmp"
"fmt"
validatorerrors "github.com/octohelm/courier/pkg/validator/errors"
"reflect"
"sync"

"github.com/octohelm/courier/internal/jsonflags"
validatorerrors "github.com/octohelm/courier/pkg/validator/errors"

"github.com/go-json-experiment/json/jsontext"
"github.com/octohelm/courier/internal/jsonflags"
"github.com/octohelm/courier/pkg/validator/internal/rules"
)

Expand Down Expand Up @@ -277,11 +276,12 @@ func (o *wrapValidator) Key() ValidatorOption {
}

func (o *wrapValidator) Validate(value jsontext.Value) error {
if !o.optional {
switch value.Kind() {
case 'n':
return &validatorerrors.ErrMissingRequired{}
switch value.Kind() {
case 'n':
if o.optional {
return nil
}
return &validatorerrors.ErrMissingRequired{}
}
if o.underlying == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/validator/taggedunion/tagged_union.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func UnmarshalDecode(dec *jsontext.Decoder, ut Type) error {

if v, ok := ut.Mapping()[discriminatorValue]; ok {
if err := validator.UnmarshalDecode(jsontext.NewDecoder(buf), v); err != nil {
return err
return validatorerrors.PrefixJSONPointer(err, dec.StackPointer())
}
ut.SetUnderlying(v)
return nil
Expand Down

0 comments on commit 059bbf4

Please sign in to comment.