(val any)
| 297 | } |
| 298 | |
| 299 | func (d DynamicArrayInput) DecodeInput(val any) (Input, error) { |
| 300 | switch x := val.(type) { |
| 301 | case []any: |
| 302 | arr := DynamicArrayInput{ |
| 303 | Elem: d.Elem, |
| 304 | } |
| 305 | decoder := d.Elem.Decoder() |
| 306 | for _, elem := range x { |
| 307 | decoded, err := decoder.DecodeInput(elem) |
| 308 | if err != nil { |
| 309 | return nil, err |
| 310 | } |
| 311 | arr.Values = append(arr.Values, decoded) |
| 312 | } |
| 313 | return arr, nil |
| 314 | case string: // default |
| 315 | var vals []any |
| 316 | dec := json.NewDecoder(strings.NewReader(x)) |
| 317 | dec.UseNumber() |
| 318 | if err := dec.Decode(&vals); err != nil { |
| 319 | return nil, fmt.Errorf("decode %q: %w", x, err) |
| 320 | } |
| 321 | return d.DecodeInput(vals) |
| 322 | default: |
| 323 | return nil, fmt.Errorf("expected array, got %T", val) |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | var _ Input = DynamicArrayInput{} |
| 328 |
nothing calls this directly
no test coverage detected