v0.5.0
Additions
-
Check
marker now accepts functions as well as string expressions:function complexValidation(value: unknown) { // Do validation... } type ComplexValidator = Check<typeof complexValidation, "to pass complex validation">; function validate(user: Assert<ComplexValidator>) { // Your code... } validate('1234' as ComplexValidator);
Transpiles to:
function complexValidation(value) {} function validate(user) { if (!complexValidation(user)) throw new Error("Expected user to pass complex validation."); } validate('1234');
-
The transformer now handles importing of values used inside markers. This means that the transformer is automatically going to import error classes, as well as functions used inside
Check
s. However, it's unable to import default exports, so make sure the stuff you pass to markers isn't exported as default.
Bug fixes
- Mostly fixes #47 (see above for more info)
Changes
Min
,Max
,MinLen
andMaxLen
are now inclusive (#51)