Some of what you ask for is impossible in a static type system for a Turing-complete language.
If you want it to happen at runtime, you could accomplish something almost exactly as you describe with macros in multiple mainstream languages. Or, as you alluded, just use business logic.
You'd probably enjoy a more declarative language like Haskell, honestly.