PHPackages                             hassankhan/affirm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. hassankhan/affirm

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

hassankhan/affirm
=================

A simple validation library for PHP 5.4+

37PHP

Since Feb 5Pushed 11y ago1 watchersCompare

[ Source](https://github.com/hassankhan/affirm)[ Packagist](https://packagist.org/packages/hassankhan/affirm)[ RSS](/packages/hassankhan-affirm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Affirm
======

[](#affirm)

[![Latest version](https://camo.githubusercontent.com/de7ed47c15f248daafd0e599c6bcce4bb5222cbe109b2db42d7d1735c09bf06e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f68617373616e6b68616e2f61666669726d2e7376673f7374796c653d666c61742d737175617265)](https://github.com/hassankhan/affirm/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/537fce1af63c8adc00c652bb7ffc8b1c4fc7ead77b9c06a4e3bc71b285111ede/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f68617373616e6b68616e2f61666669726d2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/hassankhan/affirm)[![Coverage Status](https://camo.githubusercontent.com/062454ccf9ee6e8d0bae59db4a284805eb90b1eea55f4853a32337f25860f2c6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f68617373616e6b68616e2f61666669726d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/hassankhan/affirm/code-structure)[![Quality Score](https://camo.githubusercontent.com/c388783c595a917b307497000e61e614db8cc87df62274e5df5c5d87b5963297/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f68617373616e6b68616e2f61666669726d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/hassankhan/affirm)[![Total Downloads](https://camo.githubusercontent.com/fdafd4474ead190bb12b404e89656115a5e1a3ade41b9c2e698e4b76fc5bf6c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68617373616e6b68616e2f61666669726d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hassankhan/affirm)

Affirm is a simple, no-frills assertion/validation package written for PHP 5.4+. It is a PHP port of [is.js](http://arasatasaygin.github.io/is.js/).

It is quite similar to [Assert](https://github.com/beberlei/assert), and aims to match it.

Install
-------

[](#install)

Via Composer

```
$ composer require hassankhan/affirm
```

Usage
-----

[](#usage)

First instantiate the class:

```
$affirm = new Affirm\Affirm()
```

You can use either `Affirm::is()` or `Affirm::are()` to pass in any values:

```
$affirm->is(25, 50, 75);
$affirm->are(25, 50, 75);
```

Once all values have been passed in, you can use a modifier. By default, Affirm will only return `true` if all values pass the test, you can change this like so:

```
$affirm->is(25, 50, 75)->any();
```

Then add your test:

```
$affirm->is(25, 50, 75)->any()->odd();
```

You can also use Affirm as a static class:

```
Affirm\Proxy::is(25, 50, 75)->any()->odd();
```

Please read the API documentation for a full list of available methods.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Hassan Khan](https://github.com/hassankhan)
- [All Contributors](https://github.com/hassankhan/affirm/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE.md](LICENSE.md) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1781985?v=4)[Hassan Khan](/maintainers/hassankhan)[@hassankhan](https://github.com/hassankhan)

---

Top Contributors

[![hassankhan](https://avatars.githubusercontent.com/u/1781985?v=4)](https://github.com/hassankhan "hassankhan (25 commits)")

### Embed Badge

![Health badge](/badges/hassankhan-affirm/health.svg)

```
[![Health](https://phpackages.com/badges/hassankhan-affirm/health.svg)](https://phpackages.com/packages/hassankhan-affirm)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
