mirror of
https://github.com/swc-project/swc.git
synced 2025-01-04 19:47:10 +03:00
18 lines
489 B
TypeScript
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);
|
||
|
}
|
||
|
};
|
||
|
}
|