Reputation: 1
In REGO language how can we validate if an input exists? I got one way to do this.
package play
default hello = false
hello {
input.message
}
But is this the right approach? Or is there a better way?
Upvotes: 0
Views: 1112
Reputation: 1
package play
default inputcheck = false
inputcheck {input["message"]}
This returns true if the key 'message' exist in your input . Else it returns default false
Upvotes: 0
Reputation: 2360
No, that is the right way. In the rare case where you'll need to account for the possibility of input.message
being set, but be assigned the value false
, you could use unification to check for that:
package play
hello {
_ = input.message
}
But 99% of the times, your solution is what I'd go with.
Upvotes: 0