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

16 lines
448 B
TypeScript

// Loaded from https://deno.land/x/validasaur/src/rules/is_numeric.ts
import type { Validity } from "../types.ts";
import { invalid } from "../utils.ts";
export function isNumeric(value: any): Validity {
if (typeof value !== "string" && typeof value !== "number") {
return invalid("isNumeric", { value });
}
if (typeof value === "string" && !(value as string).match(/\d+(\.\d+)?/)) {
return invalid("isNumeric", { value });
}
}