Modeling Valid Domain Objects in TypeScript with self-assert
“If your software is a model of a real-world problem, shouldn’t it be valid from the start?” self-assert is a small TypeScript library that helps you build objects that are responsible for their own validity. Instead of placing validation in external schemas, DTOs, controllers, or UI forms, self-assert helps you express rules as part of the domain model itself. Inspired by Hernán Wilkinson’s Diseño a la Gorra series, this library promotes a mindset where validation is: Internal, not external — rules live where the object lives Declarative — what makes something valid is expressed clearly and directly Encouraging valid construction — objects are built valid from the start, not checked after

“If your software is a model of a real-world problem, shouldn’t it be valid from the start?”
self-assert
is a small TypeScript library that helps you build objects that are responsible for their own validity.
Instead of placing validation in external schemas, DTOs, controllers, or UI forms, self-assert
helps you express rules as part of the domain model itself.
Inspired by Hernán Wilkinson’s Diseño a la Gorra series, this library promotes a mindset where validation is:
- Internal, not external — rules live where the object lives
- Declarative — what makes something valid is expressed clearly and directly
- Encouraging valid construction — objects are built valid from the start, not checked after