Reputation: 51
I was following google common expression language specification, can some one guide me if i could do something like this:
I need to write an expression to find if "345" is in the phone_numbers list using google CEL .
json : {"phone_numbers": ["123","234","345"] }
example : phone_numbers.exist_one("345"); // this does not works ....
https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions
Upvotes: 3
Views: 5300
Reputation: 171
Since you're just testing for the existence of a single value in a list, I would recommend using the in
operator:
'345' in phone_numbers
The exists_one
macro is pretty useful if '345'
can only appear exactly once in the list.
Upvotes: 3