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

18 lines
489 B
TypeScript

// Loaded from https://deno.land/x/validasaur/src/rules/min_length.ts
import type { Validity, Rule } from "../types.ts";
import { invalid } from "../utils.ts";
export function minLength(minValue: number): Rule {
return function minLengthRule(value: any): Validity {
if (typeof value !== "string") {
return invalid("minLength", { value, minValue }, false);
}
if (value.length < minValue) {
return invalid("minLength", { value, minValue }, false);
}
};
}