swc/crates/swc_bundler/tests/.cache/deno/80d3a662bbb6cd8904908eed9876399632b3be80.ts

18 lines
489 B
TypeScript
Raw Normal View History

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