# Assert (beberlei/assert)

> Thin assertion library for input validation in PHP business models and libraries

Source: https://talira.ai/catalog/assert-beberlei-assert-msq1hrzr
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / validation / values](https://talira.ai/categories/libraries/validation/values), [languages / php](https://talira.ai/categories/languages/php)
- Licence: BSD-2-Clause[^1][^2]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [Benjamin Eberlei](https://talira.ai/orgs/beberlei.md)

Assert is Benjamin Eberlei's PHP library of assertions and guard methods for validating input (not filtering it) in business models, libraries and low-level application code: each check, such as `Assertion::notEmpty()` or `Assertion::digit()`, throws an exception when it fails, which removes if-clauses from your code and implements pre- and post-conditions. It's deliberately low-level and fast, without the objects, locales and translations of Symfony's or Zend's validators. It has a long list of assertions, `nullOr` and `all` helpers, a fluent `Assert::that()` chain, lazy assertions that collect every failure into one exception, custom exception messages and your own assertion class.

## Links

- GitHub: https://github.com/beberlei/assert

## Problems it solves

- validate method arguments in my PHP domain model without writing if statements everywhere
- check pre-conditions in a PHP library and throw a clear exception
- collect every validation error for a value at once in PHP

## Features

- static assertion methods that throw on failure
- nullOr and all helpers
- fluent Assert::that() chains
- lazy assertions that report every failure at once
- custom exception messages and your own assertion class

## Trust

Overall: 0.50 out of 1.
Signals: maintenance 0.61, adoption 0.68, momentum 0.35, community 0.76, backing 0.30, extensibility 0.00.

- last commit 24 days ago
- 1 commits in the last 90 days
- latest release v3.3.4 5 months ago
- 2.4k GitHub stars
- 77 contributors
- backed by Benjamin Eberlei

## Alternatives

- [Webmozart Assert](https://talira.ai/catalog/webmozart-assert-6tqdb9wm.md): Assertions to validate PHP method input and output with clear error messages
- [Respect\\Validation](https://talira.ai/catalog/respect-validation-bvq8v2b5.md): Fluent validation engine for PHP with more than 150 validators

## Sources

[^1]: https://github.com/beberlei/assert/blob/master/LICENSE (checked 28 Nov 2026)
[^2]: https://github.com/beberlei/assert/blob/master/composer.json (checked 28 Nov 2026)
