Skip to content

How to evaluate non-existence of a value/attribute as true #258

Discussion options

You must be logged in to vote

I suggest you use multiple allow rule bodies -- they will be implicitly OR'ed together. So something along these lines:

default allow = false

allow { # absent key
	not has_key(data.object, "value")
}

allow { # if it's there, it's got to be "1"
	data.object.value == "1"
}

See also this playground

Replies: 1 comment 3 replies

Comment options

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

@srenatus
Comment options

@Kamalakannangv
Comment options

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