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

16 lines
403 B
TypeScript

// 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 });
}
}