Skip to content
Snippets Groups Projects
Commit 1f4cc53d authored by Danis Kirasirov's avatar Danis Kirasirov
Browse files

fix

parent fe763db2
No related branches found
No related tags found
No related merge requests found
......@@ -296,9 +296,10 @@ func (i *Item) Encode(ctx context.Context, s *schema.Schema) (*Item, error) {
func (i *Item) Decode(ctx context.Context, s *schema.Schema, opts ...field.EncodeOption) (*Item, error) {
res := *i
var err error
opt := field.NewEncodeOptions(opts...)
if i.Data != nil {
res.Data, err = s.Decode(ctx, i.Data, opts...)
if err != nil {
if err != nil && !opt.GetDataWithErrors {
return nil, err
}
}
......@@ -310,7 +311,7 @@ func (i *Item) Decode(ctx context.Context, s *schema.Schema, opts ...field.Encod
continue
}
dt, err := schema.Decode(ctx, s, v, opts...) //nolint:govet // err shadows
if err != nil {
if err != nil && !opt.GetDataWithErrors {
return nil, err
}
res.Translations[l] = dt.(map[string]interface{})
......
......@@ -153,8 +153,9 @@ func (s *Schema) Decode(ctx context.Context, v interface{}, opt ...field.EncodeO
return nil, err
}
opts := field.NewEncodeOptions(opt...)
v, err := Decode(ctx, s, v, opt...)
if err != nil {
if err != nil && !opts.GetDataWithErrors {
return nil, err
}
res, _ := v.(map[string]interface{})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment