Pretty easy to add runtime validation at the edges with Zod https://github.com/colinhacks/zod
Great thing is that the zod schema also doubles as your typescript type so you don't have to write a duplicate/shadow TS type definition.
Great thing is that the zod schema also doubles as your typescript type so you don't have to write a duplicate/shadow TS type definition.