Validate validates the overload configuration is well-formed.
()
| 414 | |
| 415 | // Validate validates the overload configuration is well-formed. |
| 416 | func (od *Overload) Validate() error { |
| 417 | if od == nil { |
| 418 | return errors.New("invalid overload: nil") |
| 419 | } |
| 420 | if od.ID == "" { |
| 421 | return errors.New("invalid overload: missing overload id") |
| 422 | } |
| 423 | var errs []error |
| 424 | if od.Target != nil { |
| 425 | if err := od.Target.Validate(); err != nil { |
| 426 | errs = append(errs, fmt.Errorf("invalid overload %q target: %w", od.ID, err)) |
| 427 | } |
| 428 | } |
| 429 | for i, arg := range od.Args { |
| 430 | if err := arg.Validate(); err != nil { |
| 431 | errs = append(errs, fmt.Errorf("invalid overload %q arg[%d]: %w", od.ID, i, err)) |
| 432 | } |
| 433 | } |
| 434 | if err := od.Return.Validate(); err != nil { |
| 435 | errs = append(errs, fmt.Errorf("invalid overload %q return: %w", od.ID, err)) |
| 436 | } |
| 437 | return errors.Join(errs...) |
| 438 | } |
| 439 | |
| 440 | // AsFunctionOption converts the serializable form of the Overload into a function declaration option. |
| 441 | func (od *Overload) AsFunctionOption(tp types.Provider) (decls.FunctionOpt, error) { |
no test coverage detected