Validation with Type Guards and Mapped Types

Slightly enhanced version of the code is now on NPM and GitHub.
Having spent a significant portion of my programming career using dynamic languages, I understand the value of rapid prototyping and feedback that they provide. I’ve also seen enough dynamic code to know that most dynamic codebases are full of brittle validation logic that our brethren from the statically typed camp don’t have to deal with. Well, that’s not entirely true. They still have to deal with it, but I think they have an easier time because the compiler can help them. There are many solutions to dealing with this problem in the dynamic camp in the form of libraries and DSLs, but today I’m going to present a solution that uses nothing but TypeScript’s built-in capabilities to help us build validators for POJOs (plain old JavaScript objects).