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

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

kashiuno/task-validator
=======================

Custom validator

00PHP

Since Nov 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/kashiuno/task-validator)[ Packagist](https://packagist.org/packages/kashiuno/task-validator)[ RSS](/packages/kashiuno-task-validator/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Validator project for test task.
================================

[](#validator-project-for-test-task)

### Install and requirements

[](#install-and-requirements)

Package published on packagist. You may install it by composer.

Command: composer require kashiuno/task-validator:dev-master

Package require php7.4 or later.

### Using

[](#using)

You may use validators on classes which extends the AbstractForm class.

##### 1. Specify rules:

[](#1-specify-rules)

When you extend AbstractForm class you may override rules() method which must return array with rules

Example:

```
public function rules(): array
{
    return [
        [
            'name' => new RegExpValidator(
                'Specified string is not match the pattern',
                ['expression' => '/\\d/', 'match' => true]
            ),
        ],
        ['name' => new RequireValidator('Name must be specify')],
        [
            'name' => new CallableValidator(
                'Name not assert to callable', [
                'callback' => function ($value) {
                    return is_string($value);
                },
            ]
            ),
        ],
        ['age' => new RequireValidator('Age must be specify')],
    ];
}

```

Notice: your form class must contain the fields specified in rules

##### 2. Using in client side

[](#2-using-in-client-side)

After instantiating form you may run load() method to initialize fields from array

Each element of array must have key equals the field name, other array keys should ignore

Example:

```
$form = new Form();
$form->load(['name' => 'John', 'surName' => 'Moore', 'age' => 24]);

```

Then you run method validate() that run all validate rules which returned by rules() method. validate() method return true or false

You may run the getErrors() method to get validation errors

```
$form = new Form();
$form->validate();
$form->getErrors();

```

##### 3. Validators

[](#3-validators)

All validators may accept error message and configuration assoc array

###### Callable validator

[](#callable-validator)

config: \['callback' =&gt; Callable\]

Callback is mandatory

Example:

```
 $validator = new CallableValidator('message', ['callback' => fn ($value) => is_string($value)]);

```

###### RegExp validator

[](#regexp-validator)

config: \['expression' =&gt; string, 'match' =&gt; bool\]

Expression is mandatory

Example:

```
$validator = new RegExpValidator('message', ['expression' => '/\d/', match => false]);

```

Match parameter meaning should the string match the expression

###### Require validator

[](#require-validator)

Example:

```
$validator = new RequireValidator('message');

```

###### String validator

[](#string-validator)

config: \['strict' =&gt; bool\]

Example:

```
$validator = new StringValidator($this->message, ['strict' => true]);

```

If strict parameter specified validator check strict type of value else don't check and pass

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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/49453693?v=4)[kashiuno](/maintainers/kashiuno)[@kashiuno](https://github.com/kashiuno)

---

Top Contributors

[![kashiuno](https://avatars.githubusercontent.com/u/49453693?v=4)](https://github.com/kashiuno "kashiuno (9 commits)")

### Embed Badge

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

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

###  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)
