PHPackages                             gd-75/request-body-validator - 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. gd-75/request-body-validator

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

gd-75/request-body-validator
============================

A simple PSR-7 compatible request body content validator

1.3.0(4y ago)1328MITPHPPHP &gt;=7.4

Since Mar 23Pushed 4y agoCompare

[ Source](https://github.com/gd-75/request-body-validator)[ Packagist](https://packagist.org/packages/gd-75/request-body-validator)[ RSS](/packages/gd-75-request-body-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (9)Used By (0)

RequestBodyValidator
====================

[](#requestbodyvalidator)

A simple PHP library to make the validation of PSR-7 request's parsed bodies less of a pain to write &amp; read 2 month later.

> GUARANTEED REGEX FREE!

**Note: The doc is not up to date anymore, I'll update it eventually**

Example
-------

[](#example)

With the classic isset, empty and is\_numeric functions

```
$pb = $request->getParsedBody();
if(
    isset($pb["field"], $pb["field1"], $pb["field2"],  $pb["field3"],  $pb["field4"])
    && !empty($pb["field"]) && !empty($pb["field2"])
    && is_numeric($pb["field3"])
){
    // Do stuff
}
```

With the validator, using the `EXISTS`, `EXISTS_NOT_EMPTY` and `NUMERIC` criterias.

```
$validator = new RequestBodyValidator($request->getParsedBody());
if(
    $validator->validateMultiple(["field1", "field4"], RequestBodyValidator::EXISTS)
    && $validator->validateMultiple(["field", "field2"], RequestBodyValidator::NOT_EMPTY)
    && $validator->validateOne("field3", RequestBodyValidator::NUMERIC)
){
    // Do stuff
}
```

> Given the fact that if `field3` must be numeric, it must also exist. This is taken into account and you don't need to verify that `field3` exists before verifying that it is numeric. This also applies to `field` and `field2` with their "non-emptiness".

Doc
---

[](#doc)

> Or rather a few lines quickly pieced together to show all the options. See example above as well.

### Methods

[](#methods)

```
// Constructor, $request is your PSR-7 request object
$validator = new RequestBodyValidator($request->getParsedBody());

// validateOne, validates a single field
$validator->validateOne($name, $criteria);

// validateMultiple, validates multiple fields with the same criteria
$validator->validateMultiple([$name, $name1], $criteria);
```

### Criterias

[](#criterias)

Class ConstantPurposeEXISTSThe field existsNOT\_EMPTYThe field exists and is not emptyNUMERICThe field exists and is numericNOT\_NUMERICThe field exists and is not a numeric.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

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.

###  Release Activity

Cadence

Every ~28 days

Total

4

Last Release

1787d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ab549939012d1118eb98c706c368de08e05d8a319852db8f878c32e65b40c59?d=identicon)[gd-75](/maintainers/gd-75)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gd-75-request-body-validator/health.svg)

```
[![Health](https://phpackages.com/badges/gd-75-request-body-validator/health.svg)](https://phpackages.com/packages/gd-75-request-body-validator)
```

###  Alternatives

[aporat/store-receipt-validator

PHP receipt validator for Apple App Store and Amazon Appstore

6503.9M9](/packages/aporat-store-receipt-validator)[laminas/laminas-validator

Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria

15544.9M188](/packages/laminas-laminas-validator)

PHPackages © 2026

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