Why not look at this?
https://github.com/protectai/llm-guard - Check out the docs
Input scanners to handle incoming before you send to a LLM and Output scanners to handle raw response from LLM - Not quite sure what custom rules you are mentioning
Outside of that you can extend your schema returned to include some properties and let AI be the "rule engine" .. but that only goes so far and sometimes can be wrong..