Skip to main content

datacheck-kit

A small, zero-dependency toolkit for validating and formatting the kinds of data that show up in almost every form or import script: email addresses, phone numbers, URLs, IBANs, credit card numbers, postal codes and slugs.

It exists because most projects end up copy-pasting the same handful of regexes and checksum functions over and over. This package collects the ones worth reusing into one place, with tests and no runtime dependencies.

This is a Python port of the datacheck-kit npm package — same API surface, adapted to Python conventions (snake_case, None instead of null).

Install

pip install datacheck-kit

Usage

import datacheck_kit as dk

dk.is_valid_email("user@example.com")        # True
dk.normalize_email("  User@Example.COM ")    # "user@example.com"

dk.is_valid_url("example.com")               # False (no protocol)
dk.normalize_url("example.com/path/")        # "https://example.com/path/"

dk.is_valid_phone("+44 20 7123 4567")        # True
dk.format_phone_e164("+44 20 7123 4567")     # "+442071234567"

dk.is_valid_iban("NL91ABNA0417164300")       # True
dk.format_iban("NL91ABNA0417164300")         # "NL91 ABNA 0417 1643 00"

dk.is_valid_card_number("4111 1111 1111 1111")  # True (Luhn check)
dk.mask_card_number("4111111111111111")         # "**** **** **** 1111"

dk.is_valid_postal_code("1011 AB", "NL")     # True
dk.supported_countries()                     # ["NL", "PL", "DE", ...]

dk.slugify("Café Müller & Söhne")            # "cafe-muller-sohne"

API

Email

  • is_valid_email(value: str) -> bool
  • normalize_email(value: str) -> str | None

URL

  • is_valid_url(value: str) -> bool
  • normalize_url(value: str) -> str | None

Phone

  • is_valid_phone(value: str) -> bool — accepts E.164-style numbers (optional leading +, 8-15 digits, common separators allowed).
  • format_phone_e164(value: str) -> str | None

IBAN

  • is_valid_iban(value: str) -> bool — validates the mod-97 (ISO 7064) checksum and checks length against the issuing country when known.
  • format_iban(value: str) -> str — groups the IBAN into 4-character blocks for display.

Credit card

  • is_valid_card_number(value: str) -> bool — Luhn algorithm.
  • mask_card_number(value: str) -> str | None — keeps only the last 4 digits visible.

Postal code

  • is_valid_postal_code(value: str, country_code: str) -> bool — supports NL, PL, DE, FR, IT, AT, CH, GB, ES, FI, US.
  • supported_countries() -> list[str]

Slug

  • slugify(value: str) -> str — lower-cases, strips common Latin diacritics, and collapses everything else into hyphens.

Why not a bigger validation library?

Larger packages cover far more ground and are a better fit if you need everything they offer. datacheck-kit is for the common case: you need five or six of these checks, you don't want a dependency tree for them, and you'd rather read the source in a couple of minutes than look up documentation.

Testing

python -m unittest discover -s tests

Uses only the standard library — no test framework dependency required.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datacheck_kit-1.0.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datacheck_kit-1.0.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file datacheck_kit-1.0.1.tar.gz.

File metadata

  • Download URL: datacheck_kit-1.0.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for datacheck_kit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 91091c6114486722795fa776f71d05d4c349a48b4c7d8406cffd52eb86d0bf93
MD5 918ac4f061820fe3a1624f0455c1991a
BLAKE2b-256 bdad56f8faacf9194b7d7d80e54dcaea20f9e50c0a384341cd5ffcee74bd00c6

See more details on using hashes here.

File details

Details for the file datacheck_kit-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: datacheck_kit-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for datacheck_kit-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4de03844eee756e34c67444752a395296677d268d4790d2189a363364434b4c4
MD5 ecfbba0a92e48fbb59d03626964f67ea
BLAKE2b-256 6b32a4ad1293f2de1c504044fc6a710dfdcdafdd67de640e8907fa6335db48eb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page