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.0.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.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: datacheck_kit-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 557b63fec38fe93a954b73a2df9c1dc6adecf67afcfb66860ce290df1da15bae
MD5 c0a8bfef3845ebf66d8d80036c2826e6
BLAKE2b-256 d2098b43286404e25bc95f551bf21ab5b3e649a89684c59506b212f8c56cb5ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: datacheck_kit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 966493480a928d711140191680056bc9ca4b75334a9c53a2976bb629726b325f
MD5 3e4befd6934e008db6afb2f33f19bb83
BLAKE2b-256 baf42379ebc898b569bcc806520c299dd2ef3e38d20495176ad85608290ea0de

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

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