✅
Built-in Rules
required, required_if / with / without, prohibited_if, present, email, phone, uuid, date, min / max in characters or bytes, in, regex and more.
Rule strings compiled once, strict about configuration, one structured error per field.
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);
}composer require solophp/validatorRequirements: PHP 8.3+