Validate validates the function configuration is well-formed.
()
| 356 | |
| 357 | // Validate validates the function configuration is well-formed. |
| 358 | func (fn *Function) Validate() error { |
| 359 | if fn == nil { |
| 360 | return errors.New("invalid function: nil") |
| 361 | } |
| 362 | if fn.Name == "" { |
| 363 | return errors.New("invalid function: missing function name") |
| 364 | } |
| 365 | if len(fn.Overloads) == 0 { |
| 366 | return fmt.Errorf("invalid function %q: missing overloads", fn.Name) |
| 367 | } |
| 368 | var errs []error |
| 369 | for _, o := range fn.Overloads { |
| 370 | if err := o.Validate(); err != nil { |
| 371 | errs = append(errs, fmt.Errorf("invalid function %q: %w", fn.Name, err)) |
| 372 | } |
| 373 | } |
| 374 | return errors.Join(errs...) |
| 375 | } |
| 376 | |
| 377 | // AsCELFunction converts the serializable form of the Function into CEL environment declaration. |
| 378 | func (fn *Function) AsCELFunction(tp types.Provider) (*decls.FunctionDecl, error) { |
no test coverage detected