Skip to content

Solo ValidatorPHP Validation Library

Rule strings compiled once, strict about configuration, one structured error per field.

Solo Validator

Quick Example ​

php
use Solo\Validator\Validator;

$validator = new Validator();

$errors = $validator->validate(
    ['email' => 'user@example.com', 'username' => 'john_doe', 'age' => 25],
    [
        'email' => 'required|email',
        'username' => 'required|min:3|max:20',
        'age' => 'integer|min_value:18',
    ],
);

if ($errors === []) {
    echo "Validation passed!";
} else {
    // ['field' => [['rule' => 'email']], ...]
    print_r($errors);
}

Installation ​

bash
composer require solophp/validator

Requirements: PHP 8.3+

Released under the MIT License.