google / cel-spec

Common Expression Language -- specification and binary representation
https://cel.dev
Apache License 2.0
2.59k stars 216 forks source link

Checking for undeclared reference #328

Closed shmul closed 6 months ago

shmul commented 6 months ago

Hi, is there a way to check for an undeclared reference? Something similar to has(e) where e is just a variable that may have not been declared?

Cheers, Shmul

TristonianJones commented 6 months ago

The best way to approach this would be to use optional values if you're using Java or Go: https://github.com/google/cel-spec/wiki/proposal-246

// assumes e is declared as an optional_type(T) 
// where T is the desired type if provided.
e.hasValue()

This feature is coming soon for C++