regexto/validators

A curated collection of battle-tested regex patterns with PHP validation.

Maintainers

Package info

github.com/regex-to/validators-php

pkg:composer/regexto/validators

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-07-10 07:59 UTC

This package is auto-updated.

Last update: 2026-07-10 08:46:17 UTC


README

Curated, production-ready, and battle-tested regex patterns for PHP, backed by the regex.to pattern registry.

All patterns are open-source, fully tested, and visualized live on regex.to.

npm pypi crates.io packagist pkg.go.dev Tested & Visualized Live

Why regexto/validators?

  • 🔍 Tested and Visualized Live: Every single pattern in this library can be searched, tested, and visualized interactively at regex.to.
  • 🚀 Zero Dependencies: Pure PHP validation. Lightweight and lightning-fast.
  • 📁 JSON Single Source of Truth: Patterns are declared declaratively in standard JSON files shared across multiple languages.

Installation

composer require regexto/validators

Quick Start

1. Basic Validation (PHP)

<?php

require 'vendor/autoload.php';

use RegexTo\Validators\Validator;

// 1. Quick boolean test (substring match)
$isMatched = Validator::test('email', 'Please contact us at contact@regex.to'); // true

// 2. Strict full-string validation
$isValid = Validator::validate('email', 'contact@regex.to'); // true

2. Smart Type Auto-Detection

Pass an unknown string, and the validator will identify matching formats:

<?php

require 'vendor/autoload.php';

use RegexTo\Validators\Validator;

$results = Validator::detect('192.168.0.1');
echo $results[0]['pattern']['slug']; // "ipv4"

Available Patterns

Here is a curated subset of the 79+ patterns supported. View all of them and test them live at regex.to/patterns:

Slug Name Category Live Sandbox
email Email Address Internet Test Live ↗
url URL (HTTP/HTTPS) Internet Test Live ↗
ipv4 IPv4 Address Network Test Live ↗
ipv6 IPv6 Address Network Test Live ↗
hex-color Hex Color Design Test Live ↗
semver Semantic Version Dev Test Live ↗
uuid UUID Dev Test Live ↗
credit-card Credit Card Number Finance Test Live ↗
iban IBAN Finance Test Live ↗
pl-nip Polish NIP (Tax ID) Finance Test Live ↗

License

MIT