A breaking release focused on correctness, safety and developer experience. See docs/upgrading-from-1.x.md for migration notes.
- Requires PHP 8.1+ (was 7.4+).
- Unknown rules now throw
UndefinedRuleExceptioninstead of silently passing validation. - Removed dispatch to arbitrary global functions. A rule name is now only
resolved to a built-in rule or a rule registered with
extend(). Use a callback orextend()for custom logic. setLocale()/setLocaleDir()throwLocaleException, andrule()throwsException\InvalidArgumentException(both implementExceptionInterface).
- Callable rules no longer throw a
TypeError— passing a closure torule()now works as documented. - The
optionalflag no longer leaks acrossvalidation()runs. - The English
againmessage resolves correctly (was keyedrepeat). - Message keys resolve case-insensitively (
creditcardandcreditCardboth produce the credit-card message). - Argument values are no longer accidentally passed through
labels(operator precedence bug in interpolation). - Open-ended
lengthworks:length(...255)now enforces the maximum. lengthon anullvalue returnsfalseinstead of raising a warning.min/maxon arrays measure element count without an "array to string" warning.equalsandagaincompare loosely (equals(123)matches integer123).- Rule arguments are trimmed (
only(a, b, c)behaves likeonly(a,b,c)). - The built-in
slugregex pattern matches multiple characters (it was missing its+quantifier). - Corrected the Turkish
notContainsmessage.
extend()for registering reusable custom named rules with optional messages.getData()accessor.alphanumericas an alias ofalphanum.- A typed exception hierarchy under
InitPHP\Validation\Exceptionbehind theExceptionInterfacemarker.
declare(strict_types=1), typed signatures and full PHPDoc throughout.- PSR-12 via PHP-CS-Fixer and PHPStan at max level — both clean.
- Expanded test suite (86 tests) covering rules, messages, locales, the
optional lifecycle, callables,
extend()and the fixed edge cases. - GitHub Actions CI (PHP 8.1–8.4, lowest/highest deps, style, static analysis,
coverage) and
composerscripts (test,stan,cs-check,cs-fix,ci). - Documentation under
docs/.
- Unit test written.
- Fixed the issue where errors were not handled in optional data.
- The result of the last validation operation
isValid()method can be used.