Skip to content

Instantly share code, notes, and snippets.

@anderseknert
Created September 20, 2023 12:26
Show Gist options
  • Save anderseknert/9a095c1b8f95c5afe245102b93d4d10f to your computer and use it in GitHub Desktop.
Save anderseknert/9a095c1b8f95c5afe245102b93d4d10f to your computer and use it in GitHub Desktop.
Logical AND
package policy
import future.keywords.if
#
# valid_email will be assigned the value of the email variable if, and only if, # all the expressions in the body evaluate
#
valid_email := email if { # rule head, name + (optional) assignment
email := lower(input.user.email) # fails if input.user.email is undefined
endswith(email, "hooli.com") # fails unless email ends with hooli.com
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment