Skip to content

v0.5.0

Compare
Choose a tag to compare
@GoogleFeud GoogleFeud released this 02 Mar 10:54
· 51 commits to dev since this release

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 Checks. 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 and MaxLen are now inclusive (#51)