02/02/2023, 11:21 AM
Drilling down a bit more on how one might combine multiple caveats, if my tuples had a context with a "from" and "to" timestamp, and the check came with an "at" timestamp. Would this be how I check that the "at" falls between the "from" and "to"? definition user {} caveat hasStarted(timestamp from, timestamp at) { from.Before(at) } caveat notEnded(timestamp to, timestamp at) { to.After(at) } definition resource { relation linked: user with (hasStarted && notEnded) permission canAccess = linked } I am not familiar with CEL, are all these fields nullable? What would the behaviour be if the "to" field was null?


02/02/2023, 1:26 PM
looking at something like should be possible (caveats should work in the playground, doc still states they don't) - but I get the error
proto: invalid type: time.Time
when running the assertions. Dunno if bug or wrong syntax, but interesting question 🙂 @Joey @vroldanbet is it possible the playground is not playing nice with timestamp caveats, yet? see link above, I essentially copied the schema, relations and assertions from the test and i always get the error mentioned above.


02/02/2023, 2:00 PM
hah, indeed I think Joey fixed recently something with the way time is parsed, but I thought we deployed it recently
but maybe it requires yet another fix in the playground
@MattA back ti your question, you cant use expression language after
keyword. You can only use it to reference a caveat
you'd have to combine all that logic in one single caveat definition
and for timestamp operations, you can use comparison operators like
<, <=, ==, !=, >, >=


02/02/2023, 3:17 PM
Thanks all. Not sure why, but I thought the caveat checked one context variable from the tuple against one in the check. Makes perfect sense that it can use the names to access any variable. It does raise the question "what would happen if you had a variable with the same name in the tuple context and the check context?"


02/02/2023, 3:18 PM
Tuple takes precedence


02/02/2023, 3:18 PM
I hope these questions are helping the documentation writing process 😄