mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 05:32:09 +03:00
16 lines
448 B
TypeScript
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 });
|
|
}
|
|
}
|