JSPM

datacheck-api

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q31952F
  • License MIT

Validate phone numbers, credit cards, IBANs, VAT numbers, and postal codes for 40+ countries. Powered by datacheck.dev.

Package Exports

  • datacheck-api
  • datacheck-api/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (datacheck-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

datacheck

Validate phone numbers, credit cards, IBANs, VAT numbers, and postal codes for 40+ countries. Zero dependencies. Powered by datacheck.dev.

Install

npm install datacheck-api

Usage

import datacheck from "datacheck-api";

// Auto-detect type
const result = await datacheck("4111111111111111");
console.log(result.valid);           // true
console.log(result.details.brand);   // "Visa"

// Phone number with location
const phone = await datacheck("+14155551234", { type: "phone" });
console.log(phone.details.location); // "San Francisco, CA"
console.log(phone.details.type);     // "mobile"

// IBAN validation
const iban = await datacheck("DE89370400440532013000", { type: "iban" });
console.log(iban.details.bank_code); // "37040044"

// VAT number
const vat = await datacheck("DE123456789", { type: "vat" });

// Postal code (country required)
const zip = await datacheck("10001", { type: "postal", country: "US" });
console.log(zip.details.region);     // "New York"

Convenience Functions

import { validatePhone, validateCard, validateIBAN, validateVAT, validatePostal } from "datacheck-api";

await validatePhone("+44 7911 123456");
await validateCard("4111111111111111");
await validateIBAN("GB29NWBK60161331926819");
await validateVAT("FR12345678901");
await validatePostal("SW1A 1AA", "GB");

Response Format

{
  "input": "+1 (415) 555-1234",
  "type": "phone",
  "valid": true,
  "formatted": "+1 4155551234",
  "country": "US",
  "details": {
    "country_code": "1",
    "national_number": "4155551234",
    "type": "mobile",
    "area_code": "415",
    "location": "San Francisco, CA"
  },
  "reason": null
}

Options

await datacheck("4111111111111111", {
  type: "credit_card",   // "auto" | "phone" | "credit_card" | "iban" | "vat" | "postal"
  country: "US",         // ISO 3166-1 alpha-2 (required for postal codes)
  baseUrl: "https://datacheck.dev",  // for self-hosted
  timeout: 10000,        // ms
});

Supported Types

Type Countries Details Returned
Phone 30+ type, area code, location
Credit Card Universal brand, BIN, last four
IBAN 45+ bank code, check digits, BBAN
VAT 30+ format name, number body
Postal 40+ region, format

License

MIT