CEL syntax

370 views
Skip to first unread message

Chirag Sharma

unread,
Jun 13, 2023, 1:07:40 AM6/13/23
to CEL Go Discussion Forum
Hi Team,
how can I create expression like below.

exp = (actor.test-user-access[0] == "custom" && request.test.context == "xyz" && request.model.type == "abc")

env.Compile(exp)

following error is coming.

type-check error: ERROR: <input>:1:11: undeclared reference to 'user' (in container '')
 | (actor.test-user-access[0] == "custom" && request.test.context == "xyz" && request.model.type == "abc")
 | ..........^
ERROR: <input>:1:16: undeclared reference to '
access' (in container '')
 | (
actor.test-user-access[0] == "custom"" && request.test.context == "xyz" && request.model.type == "abc")
 | ...............^Exiting.

Tristan Swadell

unread,
Jun 13, 2023, 3:10:56 AM6/13/23
to Chirag Sharma, CEL Go Discussion Forum
Hi Chirag,

The `test-user-access` field is not a valid identifier, so if you are using a map, I'd use the index syntax: `actor['test-user-access'][0]`

-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cel-go-discuss/9a5f5417-4970-4d11-8b66-0761950166b2n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages