import { setAssertMessageFactory } from "https://deno.land/x/unknownutil@v3.8.0/mod.ts";
Sets the factory function used to generate assertion error messages.
Examples
Example 1
Example 1
import { setAssertMessageFactory } from "./util.ts";
import is from "./is.ts";
setAssertMessageFactory((x, pred) => {
if (pred === is.String) {
return `Expected a string, got ${typeof x}`;
} else if (pred === is.Number) {
return `Expected a number, got ${typeof x}`;
} else if (pred === is.Boolean) {
return `Expected a boolean, got ${typeof x}`;
} else {
return `Expected a value that satisfies the predicate, got ${typeof x}`;
}
});