Skip to content

How to compose batch object #244

Jul 29, 2022 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

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 a default value of false to the rule so that failure still evalutes to something, whiich would be boolean false.

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 return false r…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by lukyer
Comment options

You must be logged in to vote
3 replies
@anderseknert
Comment options

@lukyer
Comment options

@anderseknert
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants