Download the PHP package tezmanian/utils-validate without Composer
On this page you can find all versions of the php package tezmanian/utils-validate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tezmanian/utils-validate
More information about tezmanian/utils-validate
Files in tezmanian/utils-validate
Package utils-validate
Short Description Lightweight PHP validation toolkit: guard assertions, boolean rules, schema validation, strict type casting, composite predicates, and array-item validation — PHP 8.3+, no dependencies.
License MIT
Homepage https://github.com/tezmanian/tez-utils-validate
Informations about the package utils-validate
tez-utils-validate
PHP validation toolkit with guard assertions, composable rules, schema validation, strict type casting, and array-item validation. PHP 8.3+, no framework dependencies.
Installation
Package: tezmanian/utils-validate · Namespace: Tezmanian\Utils\Validate
Components
| Class | Purpose |
|---|---|
Guard |
Assertion helpers that throw on failure and return the value on success |
Rules |
Stateless boolean predicates — no exceptions, no side-effects |
Composite |
Combines predicates with AND / OR / NONE logic |
Schema |
Validates an array against a shape definition |
TypeCast |
Strict type coercion that throws instead of silently truncating |
Each |
Applies a validation rule to every item in an array |
Guard
Assertions that return the value on success, making them suitable for inline use. Throws RuntimeException by default; the exception can be overridden with a class name, an instance, or a closure.
Custom exceptions:
Rules
Stateless boolean predicates. Return true/false — never throw.
Composite
Combines multiple predicates into one using AND, OR, or NONE logic. Each method returns a Closure that can be passed directly to Guard::that().
Schema
Validates an array against a shape definition. Fails fast on the first violation and reports the dot-notation path.
Supported type strings: string, int, float, bool, array, mixed
Prefix with ? to mark a field as optional (absent or null is accepted).
On failure, an UnexpectedValueException is thrown with the dot-notation path:
TypeCast
Strict type coercion — throws UnexpectedValueException when a value cannot be unambiguously converted, unlike PHP built-ins that silently truncate or guess.
Each
Applies a validation rule to every item in an array. Fails fast on the first violation and prepends the index path to the exception message.
The original exception type is preserved, and the original exception is available via getPrevious().
Requirements
- PHP 8.3+
- No runtime dependencies
Development
License
MIT — see LICENSE.
Author: René Halberstadt