Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ go_library(
"cel.go",
"decls.go",
"env.go",
"folding.go",
"io.go",
"library.go",
"macro.go",
"optimizer.go",
"options.go",
"program.go",
"validator.go",
Expand Down Expand Up @@ -56,6 +58,7 @@ go_test(
"cel_test.go",
"decls_test.go",
"env_test.go",
"folding_test.go",
"io_test.go",
"validator_test.go",
],
Expand Down
8 changes: 8 additions & 0 deletions cel/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type Ast struct {
}

// Expr returns the proto serializable instance of the parsed/checked expression.
//
// Deprecated: prefer cel.AstToCheckedExpr() or cel.AstToParsedExpr() and call GetExpr()
// the result instead.
func (ast *Ast) Expr() *exprpb.Expr {
if ast == nil {
return nil
Expand Down Expand Up @@ -221,6 +224,11 @@ func (e *Env) Check(ast *Ast) (*Ast, *Issues) {
source: ast.Source(),
impl: checked}

// Avoid creating a validator config if it's not needed.
if len(e.validators) == 0 {
return ast, nil
}

// Generate a validator configuration from the set of configured validators.
vConfig := newValidatorConfig()
for _, v := range e.validators {
Expand Down
Loading