MCPcopy Create free account
hub / github.com/cel-expr/cel-go / Validate

Method Validate

common/env/env.go:358–375  ·  view source on GitHub ↗

Validate validates the function configuration is well-formed.

()

Source from the content-addressed store, hash-verified

356
357// Validate validates the function configuration is well-formed.
358func (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.
378func (fn *Function) AsCELFunction(tp types.Provider) (*decls.FunctionDecl, error) {

Callers 1

AsCELFunctionMethod · 0.95

Calls 2

NewMethod · 0.80
ValidateMethod · 0.65

Tested by

no test coverage detected