beberlei/assert
Thin assertion library for input validation in business models.
v3.3.4
105M downloads/mo
#493 most downloaded on Packagist
beberlei/assert
What this package is like to depend on
Last release 2 months ago
10 Jun 2026
Release timing varies
gaps range from 2 weeks to 2.6 years
Most releases are documented
notes for 45 of 62 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
63 releases · first in 2012
1 release in the last 12 months
see the full history below
Release timeline
63 releases · May 2012 to Jun 2026Releases
latest 60 of 63-
v3.3.410 Jun 2026Release notes
Open source →What's Changed
- Update GitHub Action versions by @TimWolla in #347
- Add PHP 8.5 to CI by @TimWolla in #346
- Fix copy-pasted docblock on base64 assertion by @edorian in #351
- Reject trailing newline in alnum, url and e164 by @edorian in #352
- Fix uuid() accepting {, }, and prefixes inside the string by @edorian in #353
Full Changelog: v3.3.3...v3.3.4
-
v3.3.315 Jul 2024Release notes
Open source →What's Changed
- Allow any value to be passed to Assertion::isCountable() by @Wirone in #303
- PHP 8.2 CI Support by @rogervila in #332
- Fix typo in CONTRIBUTING.md by @TimWolla in #327
- Add
.github/ export-ignoreto.gitattributesby @TimWolla in #326 - Bump minimum PHP requirement to PHP 7.1 by @Ayesh in #338
- [PHP 8.4] Fixes for implicit nullability deprecation by @Ayesh in #337
- Add PHP 8.4 to CI by @TimWolla in #341
New Contributors
- @Wirone made their first contribution in #303
- @rogervila made their first contribution in #332
- @TimWolla made their first contribution in #327
- @Ayesh made their first contribution in #338
Full Changelog: v3.3.2...v3.3.3
-
v3.3.216 Dec 2021Release notes
Open source →What's Changed
- PHP 8.1 compatible by @frankvanhest in #320
- Improve performance of Assertion Chain class by @scyzoryck in #318
New Contributors
- @frankvanhest made their first contribution in #320
- @scyzoryck made their first contribution in #318
Full Changelog: v3.3.1...v3.3.2
-
v3.3.118 Apr 2021 -
v3.3.013 Nov 2020Nothing published for this version
-
v3.3.0-beta113 Nov 2020 pre-releaseRelease notes
Open source →- #302 PHP 8 support thanks to @ptondereau
- #304 Migrate from TravisCI to Github Actions
- #296 Add
Assert::uniqueValuesthanks to @gronostajo
-
v3.2.719 Dec 2019Release notes
Open source →3.2.7 - 2019-12-19
Fixes
- Reinstated the
@methodreturn type forAssert\LazyAssertionmethods to show that the return type isLazyAssertion.
Release notes
Open source →Fixes
- Reinstated the
@methodreturn type forAssert\LazyAssertionmethods to show that the return type isLazyAssertion.
- Reinstated the
-
v3.2.610 Oct 2019Release notes
Open source →Release notes
Open source →Fixes
- Make
Assert\Assertion::stringify()UTF-8 safe (Thanks to Pedram Azimaei)
- Make
-
v3.2.510 Oct 2019Release notes
Open source →3.2.5 - 2019-10-10 - Fix the broken things release.
Notice
- Sigh!
- Richard Quadling
Fixes
- REALLY Removed dependency of the intl extension.
- Updated the Docblocks for
Assert\Assertion::all()helper to show that the value is expected to be an array.
Release notes
Open source →Notice
- Sigh!
- Richard Quadling
Fixes
- REALLY Removed dependency of the intl extension.
- Updated the Docblocks for
Assert\Assertion::all()helper to show that the value is expected to be an array.
- Sigh!
-
v3.2.410 Oct 2019Release notes
Open source →3.2.4 - 2019-10-09 - Fix the broken things release.
Notice
- It seems I've been slightly lax in verifying the signature changes and expected extensions.
Hopefully, both of these have been fixed in this version.
Truly sorry for breaking the internet!- Richard Quadling
Fixes
- Restored
\Assert\Assertion::createException()signature to 3.2.2. - Removed dependency of the intl extension. If the extension is available, then
Assert\Assertion::count(),Assert\Assertion::isCountable(),Assert\Assertion::minCount(), andAssert\Assertion::maxCount()will operate onResourceBundles. - Fixed the
@methodreturn type forAssert\LazyAssertionmethods to show that the return type isstaticfor extensions ofAssert\LazyAssertion.
NOTE : Docblock does not have the ability to differentiate between a non static@methodwhose returns type is of the subclass and a@methodthat is called statically (PSR-5#899). So the use ofstatic staticis a fudge that sort of works for IDEs that need to know about the method that MAY be overridden in a subclass.
Release notes
Open source →Notice
- It seems I've been slightly lax in verifying the signature changes and expected extensions.
Hopefully, both of these have been fixed in this version.
Truly sorry for breaking the internet!
- Richard Quadling
Fixes
- Restored
\Assert\Assertion::createException()signature to 3.2.2. - Removed dependency of the intl extension. If the extension is available, then
Assert\Assertion::count(),Assert\Assertion::isCountable(),Assert\Assertion::minCount(), andAssert\Assertion::maxCount()will operate onResourceBundles. - Fixed the
@methodreturn type forAssert\LazyAssertionmethods to show that the return type isstaticfor extensions ofAssert\LazyAssertion.
NOTE : Docblock does not have the ability to differentiate between a non static@methodwhose returns type is of the subclass and a@methodthat is called statically (PSR-5#899). So the use ofstatic staticis a fudge that sort of works for IDEs that need to know about the method that MAY be overridden in a subclass.
- It seems I've been slightly lax in verifying the signature changes and expected extensions.
-
v3.2.323 Aug 2019Release notes
Open source →Other changes
- Added type hints and documentation consistency (Thanks to Andru Cherny)
-
v3.2.223 Aug 2019 -
v3.2.128 May 2019Release notes
Open source →Fixes
- Updated regex for
Assert\Assertion::url()(Thanks to Christophe Histaesse) - Fixed broken regex for
Assert\Assertion::url()(Thanks to Menno Holtkamp)
Other changes
- Added PHP 7.3.0, PHP 7.3.1, and PHP 7.3.2 to Travis pipeline as there are differences in PCRE
- Updated docblocks for
Assert\Assertion::NullOrXxxx()to show that the first parameter can be null. - Updated docblocks for
Assert\LazyAssertionto show that the return type is$thisto aid IDE's static analysis.
- Updated regex for
-
v3.2.024 Dec 2018Release notes
Open source →Added assertions
Assertion::isCountable()(Thanks to Baptiste Clavié)Assertion::maxCount()(Thanks to Baptiste Clavié)Assertion::minCount()(Thanks to Baptiste Clavié)Assertion::nonContains()(Thanks to Baptiste Clavié)
Other changes
- Added PHP 7.3 to Travis pipeline
- Added support for
\ResourceBundleand\SimpleXMLElementtoAssertion::count().
-
v3.1.029 Oct 2018Release notes
Open source →Other changes
- Refactor assertion messages for
Assert\Assertion::notEq(),Assert\Assertion::notSame(), andAssert\Assertion::notInArray()(Thanks to Rick Kuipers)
- Refactor assertion messages for
-
v3.0.111 Oct 2018Release notes
Open source →Added assertions
Assertion::notRegex()(Thanks to Thomas Müller)
Other changes
- Upgraded regex and unit tests for
Assert\Assertion::url()to latest from Symfony/Validator
-
v3.0.004 Jul 2018Release notes
Open source →Changes
- Deprecate support for PHP < 7.0
Fixes
- An
AssertionFailedExceptionmust be aThrowable(Thanks to Marco Pivetta)
-
v2.9.928 May 2019Nothing published for this version
-
v2.9.611 Jun 2018Release notes
Open source →Fixes
- Made constraints in exceptions consistent for all assertions (Thanks to Peter Kruithof)
-
v2.9.516 Apr 2018Release notes
Open source →Fixes
- Remove DocBlock entry causing exception in third party DocBlock parser (Thanks to Koutsoumpos Valantis)
-
v2.9.409 Apr 2018Release notes
Open source →Fixes
- Prevent date overflow in Assertion::date() by reset preset date value (Thanks to Nobuhiro Nakamura)
-
v2.9.316 Mar 2018Release notes
Open source →Changes
- Expand error for
\Assert\Assertion::count()to include the supplied count (Thanks to Yoann Blot)
- Expand error for
-
v2.9.225 Jan 2018Release notes
Open source →Fixes
- Usage of custom extended Assertion class in LazyAssertion (Thanks to Marek Štípek)
-
v2.9.125 Jan 2018Release notes
Open source →Deprecation notice
- Support for PHP 5 will be dropped at the end of 2018, in line with PHP's supported versions.
Fixes
\Assert\Assertion::generateMessage()will now receive the default message for an assertion if one is not supplied (Thanks to Romans Malinovskis)
-
v2.8.130 Nov 2017Release notes
Open source →Fixes
Assertion::integerish()has had several issues in the last couple of versions.
Hopefully these are now fixed. Thanks to Erik Roelofs and Michał Mleczko
Deprecation notice
- The functions
\Assert\that(),\Assert\thatAll(),\Assert\thatNullOr(), and\Assert\lazy()are no longer marked as deprecated.
Both the functional and static constructors work together. Whichever you wish to use is a personal preference.
-
v2.7.1113 Nov 2017Release notes
Open source →Fixes
Assertion::integerish(0)andAssertion::integerish('0')now assert correctly.
-
v2.7.1013 Nov 2017 -
v2.7.913 Nov 2017Release notes
Open source →Fixes
Assertion::integerish()now correctly asserts integers with leading zeros in strings (Thanks to Albert Casademont)
-
v2.7.820 Oct 2017Release notes
Open source →Fixes
Assertion::integerish()now throws exception as expected (Thanks to Thomas Flack)
-
v2.7.718 Oct 2017Release notes
Open source →Fixes
- Basic Auth usernames and passwords can contain '.' (Thanks to Fede Isas)
-
v2.7.604 May 2017 -
v2.7.526 Apr 2017Release notes
Open source →Added assertions
Assert\Assertion:isResource()(Thanks to Timothy Younger)
Other changes
- Corrected doc-block for
Assert\Assertion::propertiesExist().
-
v2.7.414 Mar 2017Release notes
Open source →Added assertions
Assert\Assertion::objectOrClass()(Thanks to Timothy Younger)Assert\Assertion::propertyExists()(Thanks to Timothy Younger)Assert\Assertion::propertiesExist()(Thanks to Timothy Younger)
Other changes
- Unit tests no longer using deprecated exception methods (Thanks to Richard Quadling)
- All global namespaced functions have been optimised (Thanks to Andreas Möller)
-
v2.7.324 Jan 2017Release notes
Open source →Fixes
- Fix
Assert\Assertion::integerish()when used with a resource (Thanks to manuxi)
- Fix
-
v2.7.209 Jan 2017 -
v2.7.106 Jan 2017Release notes
Open source →Added assertions
Assert\Assertion::extensionVersion()(Thanks to Timothy Younger)Assert\Assertion::phpVersion()(Thanks to Timothy Younger)Assert\Assertion::version()(Thanks to Timothy Younger)
Other changes
- Exception messages can now be constructed via a callback.
- Documentation now includes types.
-
v2.6.904 Jan 2017Release notes
Open source →Added assertions
Assert\Assertion::defined()(Thanks to Timothy Younger)Assert\Assertion::extensionLoaded()(Thanks to Timothy Younger)
Other changes
- Added types to generated documentation.
- Added PHPStan analysis for PHP 7+
-
v2.6.805 Dec 2016Release notes
Open source →Fixes
- All exceptions thrown by this library extend
\Assert\InvalidArgumentException(Thanks to Richard Quadling)
Other changes
- Update to php-cs-fixer ^2.0 release (Thanks to Raphael Stolt)
- Simplify XDebug disabling for Travis (Thanks to Raphael Stolt)
- Use PSR-4 autoloading (Thanks to Andreas Möller)
- Enable Composer package sorting (Thanks to Raphael Stolt)
- Fix grammar in documentation (Thanks to Adrian Föder)
- All exceptions thrown by this library extend
-
v2.6.714 Nov 2016Release notes
Open source →Fixes
- Fix the interfaceExists assertion
- Fixed issue in document generator (Thanks to Taco van den Broek)
Other changes
- Added ability to capture multiple errors on a single value in a chain (Thanks to Alec Carpenter)
- Use static factory methods instead of functions in the Assert namespace (Thanks to Taco van den Broek)
Deprecation notice
- The functions in the Assert namespace (
\Assert\that(),\Assert\thatAll(),\Assert\thatNullOr()and\Assert\lazy()) are now marked as deprecated. They will be removed in the next major release. They have been replaced with the static methods\Assert\Assert::that(),\Assert\Assert::thatAll(),\Assert\Assert::thatNullOr()and\Assert\Assert::lazy()
-
v2.6.631 Oct 2016 -
2.6.511 Oct 2016Release notes
Open source →Added assertions
Assert\Assertion::between()Assert\Assertion::betweenExclusive()
Fixes
- Allow
http://localhostas a valid URL - fixes Assertion::url('http://localhost') not a valid url?
Other changes
- Upgraded regex and unit tests for
Assert\Assertion::url()to latest from Symfony/Validator - Added PHP-CS
- Speed up of builds for Travis
-
v2.6.403 Oct 2016Release notes
Open source →Added assertions
Assert\Assertion::e164()- The international public telecommunication numbering planAssert\Assertion::interfaceExists()Assert\Assertion::ip()/Assert\Assertion::ipv4()/Assert\Assertion::ipv6()Assert\Assertion::keyNotExists()Assert\Assertion::null()Assert\Assertion::satisfy()- Allows for a bespoke assertion, rather than a predefined one
Fixes
- Improved the reporting of the value for min and max assertions
Other changes
- Removed
composer.lockfile from library - Improved travis build to detect incorrect documentation changes
-
v2.6.328 Jul 2016Release notes
Open source →Added assertions
Assert\Assertion::notInArray()
Fixes
- Made
Assert\Assertion::INVALID_GREATER_OR_EQUALunique
Other changes
- Introduced CONTRIBUTING.md to get contributors to generate the docblocks when a new assertion is added
- Introduced .editorconfig to allow IDEs that support EditorConfig to provide a consistent code style. See EditorConfig for further details
- Additional tests and updated documentation.
- Travis updates.
-
v2.6.226 Jul 2016 -
v2.6.126 Jul 2016 -
v2.5.225 Jul 2016Release notes
Open source →Other changes
- Updated tests
- Updated
generate_method_docs.phpand regenerated all documentation - Added Richard Quadling as collaborator
-
v2.5.120 Jun 2016 -
v2.0.126 Jan 2014Release notes
Open source →Other changes
- Pass constraints and values to
Assert\AssertionFailedException
- Pass constraints and values to
-
v2.626 Jul 2016Nothing published for this version
-
v2.522 Mar 2016Nothing published for this version
-
v2.421 Aug 2015Nothing published for this version
-
v2.318 Dec 2014Nothing published for this version
-
v2.218 Dec 2014Nothing published for this version
-
v2.106 Nov 2014Nothing published for this version
-
v2.026 Jan 2014Nothing published for this version
-
v1.725 Jan 2014Nothing published for this version
-
v1.605 Nov 2013Nothing published for this version
-
v1.501 Oct 2013Nothing published for this version
-
v1.407 Jul 2013Nothing published for this version
-
v1.302 Feb 2013Nothing published for this version