Version 3.0 is a major release that modernizes the API, improves error handling, and introduces powerful new validation features. This release contains breaking changes and requires migration efforts from v2.x.
- PHP 8.5+ required (v2.x required PHP 8.1+)
- Main entry point renamed to
ValidatorBuilder(globalvalias available) - Unified
ValidationException(validator-specific and nested exceptions removed) validate()now returns a ResultQuery object- Use
isValid()for boolean checks
- Use
- Significant validator changes:
Attributereplaced byProperty,PropertyOptional,PropertyExistsKeysplit intoKey,KeyOptional,KeyExistsMin/Maxsemantics changedNotBlank,NotEmpty,NoWhitespacelogic inverted (with new shortcuts)LengthandSizenow use composition instead of scalar arguments
- Several validators removed or renamed (
Type,Yes,No,Age,KeyNested, etc.) - Custom message methods
setName()andsetTemplate()removed - Validator factory replaced by a DI container via
ContainerRegistry - Custom validators now define message templates using PHP attributes
- Result-based validation API with rich inspection tools
- Find errors by path, name, or validator ID
- New validators, including:
Attributes,All,BetweenExclusive,DateTimeDiffShortCircuit,Formatted,ContainsCountFactory,Named,Templated
- Prefixed shortcuts for common patterns
(nullOrEmail,allPositive,keyEmail,notBlank, etc.) - Improved error messages with full paths for nested data
- Cleaner stack traces that point to user code
- Symfony Translation Contracts support
- Template placeholder pipes for advanced message formatting
Some validators now require additional packages (e.g. ISO code validators, UUID support).
Please review the full migration guide in the docs/ folder before upgrading. Feel free to report any issues or problems you encounter.