Search by

nielsjanssen / laravel-validation

NielsJanssen

Attribute-based validation for Laravel: declare rules on object properties and validate the object directly

Package info

github.com/NielsJanssen/laravel-validation

pkg:composer/nielsjanssen/laravel-validation

Statistics

Installs: 5

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v1.0.0-beta.1 2026-09-12 14:59 UTC

This package is auto-updated.

Last update: 2026-09-12 15:13:49 UTC


README

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