@phonecheck/phone-number-validator-js
Version:
Validate, parse, and enrich international phone numbers — geocoding, carrier lookup, and timezone resolution. Sync (Node) + async (serverless) APIs, platform adapters, and a CLI.
18 lines (17 loc) • 905 B
TypeScript
import type { ValidationRequestBody } from './validation';
/**
* Map URL query params onto a `ValidationRequestBody`. `phoneNumbers` accepts
* a comma-separated list (`?phoneNumbers=+1,+44`). Boolean enrichment toggles
* accept any of `true|false|1|0|yes|no|on|off`.
*/
export declare function parseQueryParams(url: URL): ValidationRequestBody;
/** Web-API JSON response shorthand. */
export declare function jsonResponse(status: number, body: unknown, headers: Record<string, string>): Response;
/** `application/json` content-type guard for routed POST endpoints. */
export declare function requireJsonContentType(request: Request, headers: Record<string, string>): Response | null;
/** Read a JSON body, mapping parse failures to a 400 response. */
export declare function readJsonBody(request: Request, headers: Record<string, string>): Promise<{
body: unknown;
} | {
error: Response;
}>;