Add a special function that evaluates nicely with undefined arguments. #561
-
Hi I have the following policy: allow if count(errs) == 0
valid_document if {
...
}
errs contains sprintf("document must be %v but is %v", ["expected", input.document.something]) if {
not valid_document
} Unfortuntaly, if Could you please add a function that allows passing undefined documents and does something nice with them, like replace their value with For example: undef.sprintf("document must be %v but is %v", ["expected", input.document.something]) returns Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi there! There are a few ways you can achieve that with existing language constructs, but if you're looking for a built-in function specifically, errs contains sprintf("document must be %v but is %v", ["expected", something]) if {
not valid_document
something := object.get(input, ["document", "something"], "<undefined>")
} |
Beta Was this translation helpful? Give feedback.
Hi there! There are a few ways you can achieve that with existing language constructs, but if you're looking for a built-in function specifically,
object.get
would be one to reach for here.