Quick Start

This PHP validation library aims to provide a powerful yet streamlined solution for validating your data. It offers a core set of commonly used validation rules, along with the essential tools to easily define your own custom rules. The focus is on simplicity, organization, and flexibility.

Requires PHP 8.2+.

Use the validator for DTOs (Data Transfer Objects) and structured data. Avoid using it for validating complex objects like domain entities, which should enforce their validity through internal logic.

Install

This library is installed using Composer. If you don’t have Composer, you can get it from getcomposer.org.

In your project’s root directory, run the following command:

composer require norvica/validation

Instantiate

To start using the library, you’ll first create an instance of the Validator class:

use Norvica\Validation\Validator;

$validator = new Validator();

Validate

To validate a single value, use the Validator::validate().

use Norvica\Validation\Rule\Email;

$validator->validate('[email protected]', new Email());