Is your feature request related to a problem? Please describe.
Add a configuration option to only check x% of function calls, because I don't need to check the schema every time, just enough times to get a notification if something goes wrong.
Describe the solution you'd like
// Special `Assert` type get detected and generates validation code
function greet(name: Assert<string>, age: Assert<number>): string {
return `Hello ${name}, you are ${age} years old!`;
}
// Transpiles to:
function greet(name, age) {
if (Math.random() < 0.01) {
if (typeof name !== "string") throw new Error("Expected name to be a string");
if (typeof age !== "number") throw new Error("Expected age to be a number");
}
return `Hello ${name}, you are ${age} years old!`;
}
Another solution would be to create another type like ProbableAssert which does this.
It's probably not a standard for validation libraries to have this, but I thought it's a cool feature
Is your feature request related to a problem? Please describe.
Add a configuration option to only check x% of function calls, because I don't need to check the schema every time, just enough times to get a notification if something goes wrong.
Describe the solution you'd like
Another solution would be to create another type like ProbableAssert which does this.
It's probably not a standard for validation libraries to have this, but I thought it's a cool feature