Many tools use OPA for this, have you considered using it? https://www.openpolicyagent.org/docs/policy-language