Skip to content

Add a special function that evaluates nicely with undefined arguments. #561

Discussion options

You must be logged in to vote

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.

errs contains sprintf("document must be %v but is %v", ["expected", something]) if {
    not valid_document
    something := object.get(input, ["document", "something"], "<undefined>")
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gusega
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants