Upgrade
Changed
- Target Laravel 12 exclusively; Laravel 11 and earlier are no longer supported on this major line
- Raise the minimum PHP version to 8.2
- Replace the
illuminate/containerdependency withilluminate/validation(^12.0) - Bump development tooling: Orchestra Testbench
^10, Pest^3, PHPStan^2 - CI now tests PHP 8.2, 8.3, and 8.4
- Autoload the
rule()helper via Composer'sfilesautoload so it is available without a manual require in(),notIn(), andcontains()now build rules through Laravel's fluentIlluminate\Validation\Rulehelpers (values are quoted, e.g.in:"foo","bar")- Explicit nullable parameter types for PHP 8.4 compatibility (e.g.
?string $range = nullinstead of implicitly nullablestring $range = null)
Added
anyOf(array $rules)doesntContain(string ...$values)encoding(string $encoding)inArrayKeys(string ...$keys)prohibitedIfAccepted(string ...$fields)prohibitedIfDeclined(string ...$fields)- Optional custom confirmation field:
confirmed(?string $field = null) - Strict mode for numeric rules:
integer(bool $strict = false),numeric(bool $strict = false) - URL protocol restriction:
url(string ...$protocols) - UUID version restriction:
uuid(string|int|null $version = null) UnitEnumsupport forin()andnotIn()
Fixed
alphaNumeric()now emits the correct Laravel rule stringalpha_num(was incorrectlyalpha_numeric)Rule::make()no longer passes an unused$fieldargument into the Rule constructor (which could error under PHP 8+)- README password example updated to use
Password::min(...)->letters()->numbers()instead of invalid named arguments
Breaking changes
| Change | Migration |
|---|---|
| Laravel 11 (and earlier) dropped | Upgrade the application to Laravel 12, then install this version |
| PHP < 8.2 dropped | Run on PHP 8.2 or higher |
illuminate/container no longer required directly | No action for normal Laravel apps; illuminate/validation is required instead |
alphaNumeric() rule string corrected to alpha_num | Update any assertions or custom code that expected alpha_numeric |
in() / notIn() / contains() string form now quotes values | Update assertions that expected unquoted forms like in:foo,bar to in:"foo","bar" |
Rule::make(?string $field) no longer forwards $field to the constructor | If you subclassed Rule and relied on a constructor $field argument, stop depending on it (the argument remains accepted for call-site compatibility but is ignored) |
Optional method parameters such as confirmed(), integer(), numeric(), url(), and uuid() remain backwards compatible when called with no arguments.