PHPackages                             redbox/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. redbox/validator

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

redbox/validator
================

https://github.com/johnnymast/redbox-validator

v0.20(3y ago)07[4 issues](https://github.com/johnnymast/redbox-validator/issues)[1 PRs](https://github.com/johnnymast/redbox-validator/pulls)MITPHPPHP &gt;=8.1

Since Mar 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/johnnymast/redbox-validator)[ Packagist](https://packagist.org/packages/redbox/validator)[ GitHub Sponsors](https://github.com/johnnymast)[ RSS](/packages/redbox-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (8)Used By (0)

Redbox-valiation
================

[](#redbox-valiation)

Redbox-validation is a simple to use validation class. The implementation is based on Laravel's (but no a rewrite of) validation package but has no external when used in your project.

[![Packagist](https://camo.githubusercontent.com/7ab7016128cebc3a84b7d76217458c09cadbad0a58f8e073b054d0c06b743a27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726564626f782f76616c69646174696f6e2e737667)](https://packagist.org/packages/redbox/validation)[![Unit Tests](https://github.com/johnnymast/redbox-validation/actions/workflows/Tests.yml/badge.svg)](https://github.com/johnnymast/redbox-validation/actions/workflows/Tests.yml)[![PhpCS](https://github.com/johnnymast/redbox-validation/actions/workflows/Phpcs.yaml/badge.svg)](https://github.com/johnnymast/redbox-validation/actions/workflows/Phpcs.yaml)[![PhpCS](https://raw.githubusercontent.com/johnnymast/redbox-validation/master/badges/coverage-badge.svg)](https://github.com/johnnymast/redbox-validation/actions/workflows/pest-coverage.yaml)

Installation
------------

[](#installation)

```
$ composer require redbox/validation
```

Usage
-----

[](#usage)

The package is flexible to use with an easy syntax.

Basic Usage
-----------

[](#basic-usage)

```
use Redbox\Validation\Validator;

$validator = new Validator([
    'foo' => 'The quick brown fox jumps over the lazy dog'
]);

$data = $validator->validate([
    'food' => 'string'
]);

/**
 * Validator::passes() is also
 * available.
 */
if ($validator->fails()) {
    /**
     * Handle errors use $validator->errors()
     * to get the errors.
     */
}
```

Using closures
--------------

[](#using-closures)

You can use your own closures to add custom rules

```
use Redbox\Validation\ValidationContext;
use Redbox\Validation\Validator;

$validator = new Validator([
    'foo' => 'The quick brown fox jumps over the lazy dog'
]);

$data = $validator->validate([
    /**
     * This will validate field 'foo' equals 'baz' in this case it will not so
     * the validation will fail and an error will be set for field 'foo'.
     */
    'foo' => function (ValidationContext $context): bool {

        return ($context->keyExists() &&  $context->getValue() === 'baz')
            or $context->addError("Field {$context->getKey()} does not equal 'baz'.");
    }
]);

/**
 * Validator::passes() is also
 * available.
 */
if ($validator->fails()) {
    /**
     * Handle errors use $validator->errors()
     * to get the errors.
     */
    print_r($validator->errors());
}
```

Available Rules
---------------

[](#available-rules)

The following validation rules are available with this package.

TypeAliasDescriptionstringN/AThe field under validation must be of type string.booleanboolThe field under validation must be of type boolean.integerintThe field under validation must be of type integer.License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2023 Johnny Mast

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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 ~49 days

Recently: every ~61 days

Total

6

Last Release

900d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d5a228d3118e6b9e3c3c189ea1c8d3a13ed4c9ac312b9217654c81f6d4214cc8?d=identicon)[johnnymast](/maintainers/johnnymast)

---

Top Contributors

[![johnnymast](https://avatars.githubusercontent.com/u/121194?v=4)](https://github.com/johnnymast "johnnymast (65 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (26 commits)")

---

Tags

custom-rulesnodependencephppsr-12validationphpvalidation

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/redbox-validator/health.svg)

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

###  Alternatives

[yorcreative/laravel-argonaut-dto

Argonaut is a lightweight Data Transfer Object (DTO) package for Laravel that supports nested casting, recursive serialization, and validation out of the box. Ideal for service layers, APIs, and clean architecture workflows.

1062.8k1](/packages/yorcreative-laravel-argonaut-dto)

PHPackages © 2026

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