swc/bundler/tests/.cache/deno/bbf41266eb40fbf66cc74fff8e8dea6bfd472aee.ts

16 lines
403 B
TypeScript
Raw Normal View History

// Loaded from https://deno.land/x/validasaur/src/rules/is_ipv4.ts
import type { Validity } from "../types.ts";
import { invalid } from "../utils.ts";
export function isIPv4(value: any): Validity {
if (typeof value !== "string") {
return invalid("isIPv4", { value });
}
if (!value.match(/^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$/)) {
return invalid("isIPv4", { value });
}
}