A TypeScript first validation and class creation library. Learn in 10 minutes with the quickstart.
- 100% typed
- 100% tested
- Simple syntax
- Zero dependencies
- Exported in ES5
IMPORTANT: About the package size
NPM's "Unpacked Size" is innacurate because the package includes source maps and source files for easier debugging. So, the accurate size of this library for most users is this:
|Minified bundle||19.68 KB|
|Gzipped minified bundle||4.58 KB|
If you have to represent the user age in years, would you use a
string or a
number? Doesn't matter, they're both not ideal. Every age in years could be represented as a
string or as a
number, but not every
number could represent a valid age.
Value objects to the rescue: If you want an age, create an Age object.
But that's ugly, so I made this library to ease your pain.
|Package version||TypeScript version|
Creating value objects
;;; // One lowercase, one uppercase, one number
Validating / instantiating objects
;;userFromRaw; // COMPILATION ERROR: It expects a correct raw user structureapp.post'/api/create-user',;