Search by

galvaonten-coder / datacheck-kit

galvaonten-coder

Zero-dependency toolkit for validating and formatting everyday data: emails, phone numbers, URLs, IBANs, credit card numbers, postal codes and slugs.

Package info

github.com/galvaonten-coder/datacheck-kit-php

Homepage

pkg:composer/galvaonten-coder/datacheck-kit

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-09-08 22:15 UTC

This package is auto-updated.

Last update: 2026-09-08 22:17:39 UTC


README

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 PHP port of datacheck-kit (originally written for npm, also available for PyPI) — same functionality, adapted to PHP conventions (static classes, ?string nullable returns instead of null/None).

Install

composer require galvaonten-coder/datacheck-kit

Usage

use DataCheckKit\Email;
use DataCheckKit\Url;
use DataCheckKit\Phone;
use DataCheckKit\Iban;
use DataCheckKit\CreditCard;
use DataCheckKit\PostalCode;
use DataCheckKit\Slug;

Email::isValid('user@example.com');        // true
Email::normalize('  User@Example.COM ');   // 'user@example.com'

Url::isValid('example.com');               // false (no protocol)
Url::normalize('example.com/path/');       // 'https://example.com/path/'

Phone::isValid('+44 20 7123 4567');        // true
Phone::formatE164('+44 20 7123 4567');     // '+442071234567'

Iban::isValid('NL91ABNA0417164300');       // true
Iban::format('NL91ABNA0417164300');        // 'NL91 ABNA 0417 1643 00'

CreditCard::isValid('4111 1111 1111 1111'); // true (Luhn check)
CreditCard::mask('4111111111111111');       // '**** **** **** 1111'

PostalCode::isValid('1011 AB', 'NL');      // true
PostalCode::supportedCountries();          // ['NL', 'PL', 'DE', ...]

Slug::make('Café Müller & Söhne');         // 'cafe-muller-sohne'

API

DataCheckKit\Email

  • isValid(string $value): bool
  • normalize(string $value): ?string

DataCheckKit\Url

  • isValid(string $value): bool
  • normalize(string $value): ?string

DataCheckKit\Phone

  • isValid(string $value): bool — accepts E.164-style numbers
  • formatE164(string $value): ?string

DataCheckKit\Iban

  • isValid(string $value): bool — mod-97 (ISO 7064) checksum, plus a country-length check when the country is known.
  • format(string $value): string

DataCheckKit\CreditCard

  • isValid(string $value): bool — Luhn algorithm.
  • mask(string $value): ?string

DataCheckKit\PostalCode

  • isValid(string $value, string $countryCode): bool — supports NL, PL, DE, FR, IT, AT, CH, GB, ES, FI, US.
  • supportedCountries(): string[]

DataCheckKit\Slug

  • make(string $value): string

Testing

composer install
composer test

License

MIT — see LICENSE.