PHPackages                             wepesi/validation - 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. wepesi/validation

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

wepesi/validation
=================

This module has been design to help you validate data values

v2.3.0(2y ago)4221[7 issues](https://github.com/bim-g/Validator/issues)1Apache-2.0PHPPHP &gt;=7.4

Since Oct 22Pushed 1y ago2 watchersCompare

[ Source](https://github.com/bim-g/Validator)[ Packagist](https://packagist.org/packages/wepesi/validation)[ RSS](/packages/wepesi-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (18)Used By (1)

WEPESI VALIDATION
=================

[](#wepesi-validation)

Validate your input value with a simple model tools.

INTEGRATION
-----------

[](#integration)

The integration is the simple thing to do. First you need to define the rule of the input data, and easy way to do so is by using a schema model which help handle all the process, then create an instance of `Validate` which will help validate data input according to rules already defined. While have the instance of validation, you can access `check` method, with take two parameters, the `source` and `rules`; The `schema` will be used to generate the model for each data type validate, and to `validate` will define the result of the data field checked.

```
    $valid = new \Wepesi\App\Validate();
    $schema = new \Wepesi\App\Schema();
    $source = [];
    $rules = ["name" => $schema->string()->min(3)->max(5)->generate()];
    $valid->check($source,$rules);
```

- `source`The `source` is array object of information to be checked.

```
    $source=[
        "name"=>"wepesi",
        "email"=>"infos@wepesi.cd",
        "link"=>"https://github.com/bim-g/wepesi_validation/",
        "age"=>1
        ];
```

- `rules`The `rules` contains all the rule for each element of the source to be checked. you start with the name of the index key you want to check, the with the method you want to check. different method are now available according to you need.

VALIDATION METHOD
-----------------

[](#validation-method)

The schema as several method according to different data type that will help to validate your field according to your input.

- any : validate nothing
- string : validate string data
- number : validate number(integer)
- date : validate your date(datetime) not yet full supported
- boolean : validate boolean
- array : validate array data
- file :(*experimental*)

```
    // rules
    $rules=[
        "email"=>$schema->string()->email()->min(9)->max(50)->required()->generate(),
        "year"=>$schema->number()->email()->min(35)->max(60)->required()->generate()
    ];
```

in the example bellow, for the first rule

```
    "email"=>$schema->string()->email()->min(9)->max(50)->required()->generate()

    // check `email` field should be a:
    // - string     : type of the value to be checked should be a string
    // - email      : that string should be an email
    // - min=>9     : the email should have minimum of  9 character
    // - max=>50    : the email should have maximum of 50 characters
    // - required   : it should not be empty
```

Methods
-------

[](#methods)

### `any`

[](#any)

In case there you don't want to validate data sent, use this method, it will not be taken into consideration but the field should be defined.

### `string`

[](#string)

use this method your string value, it has built in method for different scenario such:

- `required` : this to specify that the key will be required means `is not null`.
- `min` : check the minimum length of a string,
- `max` : check the maximum length of a string,
- `email` : check if the value is an email,
- `url` : used to check url link,
- `matches` : this is used tho check if two key has the same value, you should specify the second field to check.
- `generate` : this methode will generate the array structure that will be used to validate the value, and should be called and the end of each element. In case it's not called there will be an error.

### supported `url` :

[](#supported-url-)

- `http(s)://[domain].[extension]` ,
- `http(s)://www.[domain].[extension]`,
- `www.[domain].[extension]`

In the example bellow, you can see a complete procured on how to validate data-source

```
    $source=[
        "name"=>"wepesi",
        "email"=>"infos@wepesi.cd",
        "link"=>"https://github.com/bim-g/wepesi_validation/",
        "age"=>1
        ];
    $validate = new \Wepesi\App\Validate();
    $schema = new \Wepesi\App\Schema();
    $rules = [
        "name"=>$schema->any(),
        "email"=>$schema->string()->required()->min(3)->max(60)->email()->generate(),
        "link"=>$schema->string()->required()->min(3)->max(60)->url()->generate(),
        "age"=>$schema->number()->required()->positive()->generate()
    ];

    $validate->check($source,$rules);
    var_dump(["passed"=>$validate->passed()]); // return true if there is no error
    var_dump(["errors"=>$validate->errors()]); // return an array with different related errors
```

After generating the schema, now it is required to validate the schema data information, from the validate instance object `three` method are available to do all the operation:

- `check` : used to validate your source data according to schema, it take two paramaters,

- the first one is the source data which need to checked and
- the second parameters is the generated schema.

- `passed` : return boolean value, is `true` if there is no problem
- `errors` : return an array, in case the `passed` return false the array will not be empty.

### `number`

[](#number)

validate integer is now quite difficult, but it required to be consistent in what you are doing.

### `date`

[](#date)

validate your date(datetime) not yet full supported

### `boolean`

[](#boolean)

validate boolean.

```
    $rules = [
        "name"=>$schema->any(),
        "email"=>$schema->string()->required()->min(3)->max(60)->email()->generate(),
        "link"=>$schema->string()->required()->min(3)->max(60)->url()->generate(),
        "age"=>$schema->number()->required()->positive()->generate(),
        "agreement" => $schema->boolean()->isValid('TRUE')->required()->generate()
    ];
```

### `array`

[](#array)

use this method to validate your array data object.

- `required` : the field should be an array,
- `min` : define minimum number of elements the field should have,
- `max` : define maximum number of elements the field should have,
- `string` : check if content of an array are string,
- `number` : check if content of an array are numbers,

```
$schema = [
    "names" => $schema->array()->min(1)->max(10)->string()->generate();
    "ages" => $schema->array()->min(2)->max(5)->number()->generate()
]
// name should be an array and should have a minimum of 1 element and maximum should be 10, each element should be a type string
// ages should be an array and should have a minimum of 2 elements and does not exceed 5, each element should be a type number
```

In some case the array can have children, and method, the array module as also it own method to control elements,

- `structure`: will allow to multidimensional array. Resources

```
$source = [
    "name" =>"wepesi",
    "email" => "info@wepesi.com",
    "possessions" => [
        "cars" => 2,
        "plane" => 0,
        "houses" => 4,
        "children" => -3,
        "children_name" => ["alfa",3,false,"rachel"],
        "children_age" => [20,"15.7","rachel"],
        "location" => [
            "goma" => "Q.Virunga 08",
            "bukabu" => "Bagira 10",
            "kinshasa" => "matadi kibala 05"
        ]
    ]
];
```

Validation Schema

```
$rules =[
  "name" => $schema->string()->min(1)->max(10)->required()->generate(),
  "email" => $schema->string()->email()->required()->generate(),
  "possessions" => $schema->array()->min(1)->max(2)->required()->structure([
      "cars" => $schema->number()->min(1)->required()->generate(),
      "plane" => $schema->number()->min(1)->required()->generate(),
      "houses" => $schema->number()->min(6)->required()->generate(),
      "children" => $schema->number()->positive()->required()->generate(),
      "children_name" => $schema->array()->string()->generate(),
      "children_age" => $schema->array()->number()->generate(),
      "location" => $schema->array()->min(2)->structure([
          "goma" => $schema->string()->min(20)->generate(),
          "bukabu" => $schema->string()->min(20)->generate(),
          "kinshasa" => $schema->string()->min(20)->generate(),
      ])->generate()
  ])->generate()
];
```

The method take an array of a schema generated. In case you want to validate array with string content use `string` from array schema `Note`: while using array you can not use `string` method or `number` with `structure` at the sametime it will cause an error, event you can not use `string` with `number` at once, it should be one or another.

```
$schema->array()->string()->structure([])->generate()
```

This will throw an error, each one should be used separately. You can check the example folder then you can get all exercises for each method.

Enjoy :)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance8

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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 ~88 days

Recently: every ~73 days

Total

9

Last Release

965d ago

Major Versions

1.8.4 → v2.x-dev2022-01-02

v2.x-dev → v3.x-dev2022-12-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b7536aed6138da14cfe4d2a295017fd44f2997ee86c689e8aa6276080164cfd?d=identicon)[ibmussa](/maintainers/ibmussa)

---

Top Contributors

[![bim-g](https://avatars.githubusercontent.com/u/16068170?v=4)](https://github.com/bim-g "bim-g (162 commits)")[![Domeshow](https://avatars.githubusercontent.com/u/60592554?v=4)](https://github.com/Domeshow "Domeshow (18 commits)")

---

Tags

array-validationdata-validationdata-validatorinput-validationinput-validatornumber-validationphp-validationstring-vallidationvalidationvalidation-util

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wepesi-validation/health.svg)

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

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