PHPackages                             mahmoud-abdelfadeil/validator-filter-php - 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. mahmoud-abdelfadeil/validator-filter-php

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

mahmoud-abdelfadeil/validator-filter-php
========================================

package to facilitate validation and filtering in PHP

v1.1(5y ago)317MITPHP

Since Feb 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/M-H-Abdelfadeil/validator-filter-php)[ Packagist](https://packagist.org/packages/mahmoud-abdelfadeil/validator-filter-php)[ RSS](/packages/mahmoud-abdelfadeil-validator-filter-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (4)Used By (0)

Validator And Filter PHP
========================

[](#validator-and-filter-php)

**package to facilitate validation and filtering in PHP**

#### Created By : Mahmoud Abdelfadeil

[](#created-by--mahmoud-abdelfadeil)

### [install](#installation)

[](#install)

### [Confige File](#ConfigeFile)

[](#confige-file)

### [Validator](#Validate)

[](#validator)

[ - Syntax](#Syntax)
[ - NotesSyntax](#NotesSyntax)
[ - string](#string)
[ - url](#url)
[ - required](#required)
[ - options](#options)
[ - ip](#ip)
[ - email](#email)
[ - max\_length](#max_length)
[ - min\_length](#min_length)
[ - max\_val](#max_val)
[ - min\_val](#min_val)
[ - uniqueAndExists](#uniqueAndExists)
[ - unique](#unique)
[ - exists](#exists)

### [Filter](#Filters)

[](#filter)

[-string](#string)
[-num\_int](#num_int)
[-num\_float](#num_float)
[-email](#email)
[-url](#url)
[-encoded](#encoded)
[-magic\_quotes](#magic_quotes)
[-special\_char](#special_char)

installation
------------

[](#installation)

1- composer require mahmoud-abdelfadeil/validator-filter-php
ConfigeFile
-----------

[](#configefile)

create config file Through the following command :
php vendor/mahmoud-abdelfadeil/validator-filter-php/src/Validator/create-file-config.php

Or create a config file by writing these lines into the composer.json file , Then command composer dump-autoload

```
{

    "scripts": {
        "post-autoload-dump": [
           "php  vendor/mahmoud-abdelfadeil/validator-filter-php/src/Validator/create-file-config.php"
        ]
    }
}
```

Then the file is created config/validator-filter-config.php

```
return [
    // config database
    "db_host"=>"localhost",
    "db_connection"=>"mysql",
    "db_name"=>"filter-validate-php",
    "db_user"=>"root",
    "db_password"=>"",

    // config langauge [ar - en]
    "lang"=>'en'
];
```

It is a settings file that makes settings for Database and language settings

Validate
--------

[](#validate)

It is intended to verify the value

There are several functions of them

### Syntax

[](#syntax)

```
/*
$arr=[
    request name = > rules
]
*/
// example
include 'vendor/autoload.php';
$validate=new ValidatorFilterPHP\ValidatorPHP();
$rules=[
    'name'=>'required|string|max_length:100|min_length:5',
    'age'=>'required|number|max_val:60|min_val:10',
    'email'=>'required|unique:users,email'
];

if(isset($_POST['submit'])){
    $validate->Validator($rules);
    if($validate->has_error_validate()){
        echo "";
        print_r( $validate->has_error_validate());
    }else{
        // next request
    }
}
```

### NotesSyntax

[](#notessyntax)

**As we noticed in the previous example, we write the name of the request, then the rules to be verified, and each rule is separated by using the ' | '**

**There are many rules that we need to write a value, for example the max\_length, which means the minimum number of characters, and the rule and value are separated using the ' : '**

### Rules

[](#rules)

#### string

[](#string)

Check the value if it is textual or not

#### number

[](#number)

Check if the value is a number or not

#### url

[](#url)

Check if the value is a url or not

#### required

[](#required)

Check if the value is empty or not

#### options

[](#options)

It forces the user to enter the specified values ​​into the options
From a rule that takes specified values ​​but is written this way :

options:\[option 1 , option 2 , .......\]

```
// example
'category'=>'required|options:[car,laptop,mobile]'
```

#### ip

[](#ip)

Check if the value is a ip or not

#### email

[](#email)

Check if the value is a email or not

#### max\_length

[](#max_length)

Checks the maximum amount of characters allowed

#### min\_length

[](#min_length)

Check the minimum number of characters allowed

**example**

```
// maximum length  100  characters
// minimum length  5    characters

'name'=>'required|max_length:100|min_length:5'
```

#### max\_val

[](#max_val)

Check the maximum allowed value

#### min\_val

[](#min_val)

Check the minimum allowed value

```
// maximum value  60
// minimum value  20

'age'=>'required|max_val:60|min_val:20'
```

\*\*Note:The max\_length or min\_length is used with the string. The max\_val and min\_val are used with numbers . In addition, they check if it is a number or not\*\* ### uniqueAndExists

[](#uniqueandexists)

Before dealing with either of them, make the database settings from the **config/validator-filter-config.php**

```
return [
    // config database
    "db_host"=>"localhost",
    "db_connection"=>"mysql",
    "db_name"=>"filter-validate-php",
    "db_user"=>"root",
    "db_password"=>"",

    // config langauge
    "lang"=>'en'
];
```

#### unique

[](#unique)

Verify that the value is not present in the data base
Synax :
unique:table,column

```
// example

'email'=>'required|unique:users,email'
```

Here, verify that email does not already exist in Databases
\*\*If modified, the identifier is sent with the unique identifier to check all rows except for the sender and write in this way The id field name for example tbl\_id and then the value that way tbl\_id = 5\*\* ```
// example  if update data

'email'=>'required|unique:users,email,tbl_id=5'
```

**If the field is named id, you only need to enter the value**

```
'email'=>'required|unique:users,email,5'
```

#### exists

[](#exists)

Synax :
exists:table,column
Verify that the value is present in the data base

```
// example

'email'=>'required|unique:users,email'
```

Filters
-------

[](#filters)

a data filter
Syntax :
$obj-&gt;functionName($data)

```
// example
$filter=new ValidatorFilterPHP\FilterPHP();
$str="mahmoud abdelfadeil";
$str_filter =  $filter->string($str);

echo $str_filter ;

// output  = mahmoud abdelfadeil
```

functions
---------

[](#functions)

#### string

[](#string-1)

```
$str="mahmoud abdelfadeil";

$str_filter =  $filter->string($str);

echo $str_filter ;

// output  = mahmoud abdelfadeil
```

#### num\_int

[](#num_int)

number integer

```
$data="mahmoud 1299 abdelfadeil";

$data_filter =  $filter->num_int($data);

echo $data_filter ;

// output  = 1299
```

#### num\_float

[](#num_float)

number float

```
$data="12.99";

$data_filter =  $filter->num_float($data);

echo $data_filter ;

// output  = 1299
```

**However, this function takes a second argument, which is the flag**
**Flags = e or E or , or .**

```
$data="12.99";

$data_filter =  $filter->num_float($data,'.');

echo $data_filter ;

// output  = 12.99
```

```
$data="12,99";

$data_filter =  $filter->num_float($data,',');

echo $data_filter ;

// output  = 12,99
```

```
$data_1="12ee9e9";

$data_1_filter =  $filter->num_float($data_1);

echo $data_1_filter ;

// output data 1   = 1299

$data_2="12ee9e9E";

$data_2_filter =  $filter->num_float($data_2,'e');

echo $data_2_filter ;

// output data 2   =  12ee9e9E

$data_3="12ee9e9E";

$data_3_filter =  $filter->num_float($data_3,'E');

echo $data_3_filter ;

// output data 3   =  12ee9e9E
```

#### email

[](#email-1)

```
$data="mahmoud .  €¶€€¶€€¶€  abdelfadeil@test.test";

$data_filter =  $filter->email($data);

echo $data_filter ;

// output data    =  mahmoud.abdelfadeil@test.test

```

#### url

[](#url-1)

```
$data="mahmoud-abdelfadeil.€¶€¶€me";

$data_filter =  $filter->url($data);

echo $data_filter ;

// output data    =  mahmoud-abdelfadeil.me

```

#### encoded

[](#encoded)

```
$data="mahmoud-abdelfadeil.€¶€¶€me";

$data_filter =  $filter->encoded($data);

echo $data_filter ;

// output data   =   mahmoud-abdelfadeil.%E2%82%AC%C2%B6%E2%82%AC%C2%B6%E2%82%ACme

```

#### magic\_quotes

[](#magic_quotes)

```
$data="mahmoud's here";

$data_filter =  $filter->magic_quotes($data);

echo $data_filter ;

// output data =  mahmoud\'s here

```

#### special\_char

[](#special_char)

```
$data="mahmoud abdelfadeil";

$data_filter =  $filter->special_char($data);

echo $data_filter ;

// output data = &#60;b&#62;mahmoud abdelfadeil&#60;/b&#62;
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Total

3

Last Release

1907d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8bb16ed9a58a9f573520b717c442b69772e304d6ef81b1190b3b277d0e5fd71?d=identicon)[m-h-abdelfadeil](/maintainers/m-h-abdelfadeil)

---

Top Contributors

[![M-H-Abdelfadeil](https://avatars.githubusercontent.com/u/60010586?v=4)](https://github.com/M-H-Abdelfadeil "M-H-Abdelfadeil (9 commits)")

### Embed Badge

![Health badge](/badges/mahmoud-abdelfadeil-validator-filter-php/health.svg)

```
[![Health](https://phpackages.com/badges/mahmoud-abdelfadeil-validator-filter-php/health.svg)](https://phpackages.com/packages/mahmoud-abdelfadeil-validator-filter-php)
```

###  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)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M448](/packages/nette-forms)[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)

PHPackages © 2026

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