Download the PHP package lukman-ss/validation without Composer
On this page you can find all versions of the php package lukman-ss/validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lukman-ss/validation
More information about lukman-ss/validation
Files in lukman-ss/validation
Package validation
Short Description A lightweight standalone PHP Validation package
License MIT
Homepage https://github.com/lukman-ss/validation
Informations about the package validation
Lukman Validation
A lightweight standalone PHP validation library with zero external runtime dependencies.
Requirements
- PHP 8.2 or higher
Installation
Install the package via Composer:
Basic Usage
Run validation using either standard boolean checks or the exception flow.
Exception Flow
Use validate() (or validateOrFail()) to directly get validated data or throw a ValidationException when validation fails.
To validate without throwing exceptions, use the safe() helper:
Rules Formatting
String Rules
Separate multiple rules with a pipe | character. Rule parameters are separated by commas ,.
Array Rules
Rules can also be provided as an array, enabling the use of rule objects and closures.
Nested Data
Validate deep nested arrays using dot notation:
Wildcard Validation
Validate all elements within an array using the wildcard * operator. Error keys will automatically map to the specific indices:
Custom Messages
Define custom messages globally per rule or specifically for a field:
Placeholders
Custom messages support the following placeholder values:
:attribute: The human-readable name of the validated field.:value: The value of the field being validated.:min: Parameter used inminorbetweenrules.:max: Parameter used inmaxorbetweenrules.:size: Parameter used in thesizerule.:other: Name of the compared field insameordifferentrules.
Custom Attributes
Translate technical field paths into user-friendly names:
Extensibility & Custom Rules
Custom Rule Objects (RuleInterface)
Create a class implementing RuleInterface:
Use it in your rules array:
Closure Rules
Define quick rules inline using Closures:
Global Factory Extensions
Register custom rules globally to use them with string rule definitions:
Post-Validation Hooks (after)
Attach callbacks that execute after standard rule evaluations. This is useful for complex, multi-field, or conditional validation checks:
Runtime Mutation
Change the dataset or rule configurations dynamically using setters. Setting new data or rules automatically clears existing errors and resets the validation state:
License
This package is open-source software licensed under the MIT License.