Valicomb

PHP 8.2+

Validation + honeycomb

A zero-dependency, security-first PHP validation library

$ composer require frostybee/valicomb

Four ways to validate

Choose the syntax that fits your coding style

Field-based Mapping
Fields to Rules
$order = [
    'drink'    => 'Cappuccino',
    'size'     => 'large',
    'quantity' => 2
];

$v = new Validator($order);
$v->forFields([
    'drink'    => ['required', ['lengthMax', 50]],
    'size'     => ['required', ['in', ['small', 'medium', 'large']]],
    'quantity' => ['required', 'integer', ['between', 1, 10]]
]);

if ($v->validate()) {
    // Brew that coffee!
}
$order = [
    'drink'    => 'Cappuccino',
    'size'     => 'large',
    'quantity' => 2
];

$v = new Validator($order);
$v->forFields([
    'drink'    => ['required', ['lengthMax', 50]],
    'size'     => ['required', ['in', ['small', 'medium', 'large']]],
    'quantity' => ['required', 'integer', ['between', 1, 10]]
]);

if ($v->validate()) {
    // Brew that coffee!
}

Group rules by field. Best for organized, field-centric validation.

Fluent Rules
Fluent Builder API
$order = [
    'drink'    => 'Flat White',
    'size'     => 'medium',
    'quantity' => 3
];

$v = new Validator($order);
$v->field('drink')
    ->required()
    ->lengthMax(50);

$v->field('size')
    ->required()
    ->in(['small', 'medium', 'large']);

$v->field('quantity')
    ->required()
    ->integer()
    ->between(1, 10);

if ($v->validate()) {
    // Brew that coffee!
}
$order = [
    'drink'    => 'Flat White',
    'size'     => 'medium',
    'quantity' => 3
];

$v = new Validator($order);
$v->field('drink')
    ->required()
    ->lengthMax(50);

$v->field('size')
    ->required()
    ->in(['small', 'medium', 'large']);

$v->field('quantity')
    ->required()
    ->integer()
    ->between(1, 10);

if ($v->validate()) {
    // Brew that coffee!
}

Chainable builder with IDE autocomplete. Great for complex validations.

Rule-based Mapping
Rules to Fields
$order = [
    'drink'    => 'Mocha',
    'size'     => 'small',
    'quantity' => 1
];

$v = new Validator($order);
$v->rules([
    'required'  => ['drink', 'size', 'quantity'],
    'integer'   => 'quantity',
    'in'        => [['size', ['small', 'medium', 'large']]],
    'between'   => [['quantity', 1, 10]]
]);

if ($v->validate()) {
    // Brew that coffee!
}
$order = [
    'drink'    => 'Mocha',
    'size'     => 'small',
    'quantity' => 1
];

$v = new Validator($order);
$v->rules([
    'required'  => ['drink', 'size', 'quantity'],
    'integer'   => 'quantity',
    'in'        => [['size', ['small', 'medium', 'large']]],
    'between'   => [['quantity', 1, 10]]
]);

if ($v->validate()) {
    // Brew that coffee!
}

Group fields by rule type. Ideal when applying the same rule to many fields.

Chaining Syntax
Fluent Chain
$order = [
    'drink'    => 'Latte',
    'size'     => 'large',
    'quantity' => 2
];

$v = new Validator($order);
$v->rule('required', ['drink', 'size', 'quantity'])
  ->rule('in', 'size', ['small', 'medium', 'large'])
  ->rule('integer', 'quantity')
  ->rule('between', 'quantity', 1, 10);

if ($v->validate()) {
    // Brew that coffee!
}
$order = [
    'drink'    => 'Latte',
    'size'     => 'large',
    'quantity' => 2
];

$v = new Validator($order);
$v->rule('required', ['drink', 'size', 'quantity'])
  ->rule('in', 'size', ['small', 'medium', 'large'])
  ->rule('integer', 'quantity')
  ->rule('between', 'quantity', 1, 10);

if ($v->validate()) {
    // Brew that coffee!
}

Chain rules one at a time. Perfect for dynamic or conditional rules.

Built for modern PHP development

Modern PHP 8.2+

Strict types, fully typed codebase with maximum static analysis at PHPStan Level 8.

Zero Dependencies

Only requires the standard ext-mbstring extension. No external packages needed.

53 Validation Rules

Comprehensive rule set covering strings, numbers, dates, arrays, networks, and more.

Security First

Built-in protection against ReDoS, type juggling, path traversal, and injection attacks.

22 Languages

Internationalization support with 22 languages included out of the box.

Easy to Extend

Add custom validation rules with simple closures or global rule registration.