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

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

webiik/validator
================

The Validator validates data against user-defined rules.

1.1(6y ago)019MITPHPPHP &gt;=7.2

Since Feb 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/webiik/validator)[ Packagist](https://packagist.org/packages/webiik/validator)[ Docs](https://www.webiik.com)[ RSS](/packages/webiik-validator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

[![](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)[![](https://camo.githubusercontent.com/20f4b99a958aadb02ff273ac6428c17cf55c6b817657ed64b1c39c7f71955a0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e2e737667)](https://camo.githubusercontent.com/20f4b99a958aadb02ff273ac6428c17cf55c6b817657ed64b1c39c7f71955a0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e2e737667)

Validator
=========

[](#validator)

The Validator validates data against user-defined rules.

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

[](#installation)

```
composer require webiik/validator
```

Example
-------

[](#example)

```
$validator = new \Webiik\Validator\Validator();

// Add input to validate and input validation rules
$validator->addInput('meow', function () {
    return [
        new \Webiik\Validator\Rules\StrLenMin(5, 'Err: Input is shorter than 5 chars.'),
        new \Webiik\Validator\Rules\StrLenMax(10, 'Err: Input is longer than 10 chars.'),
    ];
}, 'greeting');

// Validate all inputs and eventually get array of all invalid inputs
$invalid = $validator->validate(); // Array ( [greeting] => Array ( [0] => Err: Input is shorter than 5 chars. ) )
```

Adding Inputs For Validation
----------------------------

[](#adding-inputs-for-validation)

### addInput

[](#addinput)

```
addInput($input, callable $rules, string $name = '', bool $isRequired = false): void
```

**addInput()** adds an input for validation.

**Parameters**

- **input** input value
- **rules** callable that return an array of validation rule objects
- **name** optional input name. This name is used as input index in validate() result.
- **isRequired** optional. Indicates if input is required or not. Empty optional inputs are always considered as valid.

```
$validator->addInput('meow', function () {
    return [
        new \Webiik\Validator\Rules\StrLenMin(5, 'Err: Input is shorter than 5 chars.'),
        new \Webiik\Validator\Rules\StrLenMax(10, 'Err: Input is longer than 10 chars.'),
    ];
}, 'greeting', true);
```

Validation Rules
----------------

[](#validation-rules)

#### Write Custom Validation Rule

[](#write-custom-validation-rule)

You can write your custom validation rule. The only thing you have to do is to implement [RuleInterface](Rules/RuleInterface.php). Look at existing [implementation of RuleInterface](Rules/Equal.php) to get better insight.

#### Available Validation Rules

[](#available-validation-rules)

```
// Check if input is === $val
Equal($val, string $errMsg = '')
```

```
// Check if input is >= $min and = $min and = $min
StrLenMin(int $min, string $errMsg = '')
```

```
// Check if input length is validate();
```

Resources
---------

[](#resources)

- [Webiik framework](https://github.com/webiik/webiik)
- [Report issue](https://github.com/webiik/components/issues)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~160 days

Total

2

Last Release

2472d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1226362d003d186b45e7dfa44489c36af37196c6a1b476206700eaf4e9c96a5a?d=identicon)[Jiri Mihal](/maintainers/Jiri%20Mihal)

---

Top Contributors

[![Jiri-Mihal](https://avatars.githubusercontent.com/u/10408123?v=4)](https://github.com/Jiri-Mihal "Jiri-Mihal (284 commits)")

---

Tags

datavalidate

### Embed Badge

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

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

###  Alternatives

[webmozart/assert

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

7.6k894.0M1.2k](/packages/webmozart-assert)[wixel/gump

A fast, extensible &amp; stand-alone PHP input validation class that allows you to validate any data.

1.2k1.3M30](/packages/wixel-gump)[inhere/php-validate

generic data validate, filter library of the php

26787.4k13](/packages/inhere-php-validate)[sadegh19b/laravel-persian-validation

A comprehensive Laravel validation package for Persian text, numbers, dates, and Iranian national identifiers

18293.8k1](/packages/sadegh19b-laravel-persian-validation)[abcaeffchen/sepa-utilities

SepaUtilities provides useful methods for validating and sanitizing inputs used in SEPA files supporting PHP &gt;= 8.1.

312.0M2](/packages/abcaeffchen-sepa-utilities)[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65378.4k9](/packages/awurth-slim-validation)

PHPackages © 2026

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