Part 15 – Anti-Corruption Layer
This is a series of posts I’m writing about using types as another tool in software development, Continuous Delivery, & keeping LLM’s honest. They’re also a design & refactoring tool, a communication tool, and reduce how many tests you have to write.
Parts
- Part 1 – Branded Types
- Part 2 – Product Types
- Part 3 – Union & Discriminated Unions
- Part 4 – Non-Empty Collections
- Part 5 – Indexed Types
- Part 6 – unknown vs any
- Part 7 – Result
- Part 8 – Schema
- Part 9 – Total Function
- Part 10 – Errors as Values
- Part 11 – Property Tests
- Part 12 – Type Proofs
- Part 13 – Exhaustiveness Checking
- Part 14 – Parse, Don’t Validate
- Part 15 – Anti-Corruption Layer


An Anti-Corruption Layer turns someone else’s model into your own. Where unknown, schemas, & Parse, Don’t Validate convert untrusted data into trusted types, the ACL is sometimes a different layer that converts “their types to _our_ types”. Sometimes you can do this using the same Zod schema, other times it’s truly an entirely different domain boundary, shielding a legacy system away.
(more…)




