That's how the validation tool for Python Maat works. By creating a completely new dictionary. https://github.com/Attumm/Maat

For js / typescript I like: https://github.com/paperhive/fefe

basically ist’s just functions that take a value of one type and return a other one

There is also joi, zod, myzod just to name a few.

I personally use myzod as its fast it parsing, zero dependancies and you can infre types from your schemas.