Skip to content

LaraPkgs / Validation

An immutability-first, strongly typed validation package for Laravel. It replaces standard array-based validation strings with an expressive PHP API, eliminating state leaks in long-running application environments like Laravel Octane.

Why LaraPkgs/Validation?

Standard Laravel validation relies heavily on raw strings and nested arrays. While flexible, this often leads to duplicate rules across endpoints, rigid form requests, and fragile array manipulations when validating nested or repeated data structures.

LaraPkgs/Validation transforms Laravel validation into strongly typed, composable domain objects with fluent autocompletion, deterministic rule ordering, and deep prefixing.

Key Features

Object-Oriented & Fluent

Full IDE auto-completion for over 70 built-in Laravel validation rules. No more guessing string rule names or array syntax.

Composable & Reusable

Encapsulate validation logic into dedicated Validatable classes and merge them effortlessly across your application.

Deep Prefixing

Automatically prefix nested collections (e.g., items.*) while recursively updating relative rule arguments like required_if.

Rule Precedence

Automatically orders rules by logical execution priority (modifier -> circuit -> presence -> type -> constraint) to prevent unpredictable behavior.

Dynamic Error Wrapping

Wrap validation error keys on the fly during execution (e.g., data.name instead of name) without altering your core validatable definitions.

100% Immutable

Thread-safe design ensures that every mutation returns a fresh copy, eliminating unintended side effects across your application.

Native Framework Integration

Use directly in Controllers, Form Requests, or as standalone domain objects that throw standard ValidationException errors.

License

LaraPkgs/Validation is open-source software licensed under the MIT license.