Caveats | SpiceDB and AuthZed Documentat...
# spicedb
j
Hello, I was wondering if you could help me with a question about caveats in Authzed. I'm having the following caveat: caveat can_create_campaign_type(allowed_campaign_types list, campaign_type string) { // allowed_campaign_types.contains(campaign_type ) } What I'm trying to do is to check if the allowed_campaign_types contain campaign_type. I've seen here: https://authzed.com/docs/reference/caveats#parameter-types that list should be a valid type, but I'm wondering where I can find the available functions that I can use on a list. Thanks
v
👋 SpiceDB Caveats are defined as CEL expressions. The language definition can be found here: https://github.com/google/cel-spec/blob/master/doc/langdef.md#list-of-standard-definitions in particular, you should be able to write the expression as:
Copy code
caveat can_create_campaign_type(allowed_campaign_types list<string>, campaign_type string) {
  campaign_type in allowed_campaign_types
}
j
Ah, perfect. That's exactly what I was looking for, thanks 🙂