-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map Key Does Not Exist - Errors - How to write such rules with maps? #388
Comments
Custom functions works! Rule:
Custom Function worksfunc (m Magic) CategoryItemCount(category string) int {
if _, ok := m.Category[category]; !ok {
return -1
}
return m.Category[category].ItemCount
} |
There's a small mistake in your provided example - you populate the Category map with a key Regardless, this should work. You can access properties on structs in maps as expected. One key note is that this does not work for maps to interfaces! i.e. Simple things to check:
|
Fact
Rule
Fact.Category["cat2"].ItemCount > 5
This errors saying "cat2" does not exist in Category. How do you write such rules?
The text was updated successfully, but these errors were encountered: