Set a field of a protobuf to Err type #1175
Unanswered
mneff-roblox
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi there, You could do something like the following: env, err := cel.NewEnv(cel.Types(&User), cel.Variable("user", cel.ObjectType("User"))
ast, iss := env.Compile(`user.verified || user.age > 18`)
prg, err := env.Program(ast)
unkVars, err := cel.PartialVars(
map[string]any{
"user": <user>,
},
cel.AttributePattern("user").QualString("age"),
)
out, _, err := prg.Eval(unkVars) -Tristan |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there any way to do this?
Reading through the default type adapter it seems like no, but it'd be ideal if I could set individual fields to be errored.
For example if I could have a
user
proto with fieldsverified
andage
and write an expressionuser.verified or user.age > 18
, it would be nice if I could mark onlyage
as errored so that this can still evaluate to true ifverified
is trueI can already do this with a map but then lose out on type checking and stuff like that.
Beta Was this translation helpful? Give feedback.
All reactions