Looking to hire Laravel developers? Try LaraJobs

laravel-validation maintained by nielsjanssen

Description
Attribute-based validation for Laravel: declare rules on object properties and validate the object directly
Author
Last update
2026/09/12 17:13 (dev-main)
License
Downloads
5

Comments
comments powered by Disqus

[!NOTE] This is a read-only split mirror of the laravel-discovery monorepo. Please open issues and pull requests there.

laravel-validation

Attribute-based validation for Laravel. You declare validation rules directly on a class's properties or on a method's parameters, then validate in one call. The rules live next to the data they describe, so a data object carries its own validation contract.

use Illuminate\Support\Facades\Validator;
use NielsJanssen\Laravel\Validation\Rule\{Email, Max, Min};

final class Registration
{
    #[Min(2), Max(255)]
    public string $name = '';

    #[Email]
    public ?string $email = null;
}

$registration = new Registration();
$registration->name = 'Anouk de Vries';
$registration->email = 'anouk@example.nl';

Validator::validateObject($registration);

Requirements

  • PHP 8.5+
  • Laravel 13+ (illuminate/validation ^13.15)

Installation

composer require nielsjanssen/laravel-validation

The service provider registers itself through package discovery. It replaces the bound validator factory with a subclass that adds the object and method entry points, keeping the original factory's behaviour intact. There is nothing to publish.

Documentation