swc/crates/swc_bundler/tests/.cache/deno/5bf4f3eb3f5f26aa38074c84ff16223f9155bf21.ts
2021-11-09 20:42:49 +09:00

18 lines
487 B
TypeScript

// Loaded from https://deno.land/x/validasaur/src/rules/starts_with.ts
import type { Validity, Rule } from "../types.ts";
import { invalid } from "../utils.ts";
export function startsWith(str: string): Rule {
return function startsWithRule(value: any): Validity {
if (typeof value !== "string") {
return invalid("startsWith", { value, str }, false);
}
if (value.startsWith(str) === false) {
return invalid("startsWith", { value, str }, false);
}
};
}