How to compose batch object #244
-
Hi all, I have also tried comprehension with no luck. Another thing I tried is to compose several objects with truthy logic only and try to merge it in the end but merge/map is not easily doable using std lib. I must have been missing something basic 😄 Minimal example: https://play.openpolicyagent.org/p/uPp6OmMyx0 Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @lukyer! If no return value is defined for a rule or function, Rego will consider the result to be undefined on failure (i.e. if not all of the conditions in the body are true). As you noted, encountering undefined stops policy evaluation. When working with boolean rules (e.g. " Functions cannot yet have a default value assigned, so you'll commonly see either another function declaration to handle the "other" case, or simply an Your example using |
Beta Was this translation helpful? Give feedback.
-
@anderseknert thanks! That is the I have tried the |
Beta Was this translation helpful? Give feedback.
Hi @lukyer!
If no return value is defined for a rule or function, Rego will consider the result to be undefined on failure (i.e. if not all of the conditions in the body are true). As you noted, encountering undefined stops policy evaluation. When working with boolean rules (e.g. "
allow
", etc) it's a comon practice to assign adefault
value offalse
to the rule so that failure still evalutes to something, whiich would be booleanfalse
.Functions cannot yet have a default value assigned, so you'll commonly see either another function declaration to handle the "other" case, or simply an
else
clause to deal with the failure case.Your example using
else
to ensure the functions returnfalse
r…