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

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

jetfirephp/validator
====================

JetFire - Validator

6175PHP

Since Jul 27Pushed 7y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

JetFire PHP Validator
---------------------

[](#jetfire-php-validator)

A simple php validator inspired by laravel form request validation and [Respect/Validation](https://github.com/Respect/Validation).

### Installation

[](#installation)

Via [composer](https://getcomposer.org)

```
composer require jetfirephp/validator
```

### Usage

[](#usage)

Simple usage of `\JetFire\Validator\Validator` :

```
require_once __DIR__ . '/vendor/autoload.php';

$response = \JetFire\Validator\Validator::isAlpha('Peter Parker');

// if not valid
if(!$response){
    // your code
    // ...
}
```

If you want to validate multiple values you can do it like this :

```
require_once __DIR__ . '/vendor/autoload.php';

$response = \JetFire\Validator\Validator::validate([
    'Peter Parker 1'                  => 'alpha|length: 'max:30|min:10', // true
    '-20' => 'max:1|min:-30', // true
```

#### url

[](#url)

Validates if input is an URL:

```
    'http://example.com' => 'url', // true
    'https://www.youtube.com/watch?v=6FOUqQt3Kg0' => 'url', // true
```

#### boolean

[](#boolean)

Validates if the input is a boolean value:

```
    '1' => 'boolean', // true
    'true' => 'boolean', // true
```

#### date

[](#date)

Validates if input is a date:

```
    '20-01-2016' => 'date:d-m-y', // true
    '2016-01-20' => 'date:y-m-d', // true
```

#### lowercase

[](#lowercase)

Validates if string characters are lowercase in the input:

```
    'peter parker 20' => 'lowercase', // true
```

#### uppercase

[](#uppercase)

Validates if string characters are uppercase in the input:

```
    'PETER PARKER' => 'uppercase', // true
```

#### noWhitespace

[](#nowhitespace)

Validates if a string contains no whitespace (spaces, tabs and line breaks);

```
    'Peter Parker' => 'noWhitespace', // false
    'Peter-Parker' => 'noWhitespace', // true
```

#### email

[](#email)

Validates an email address.

```
    'peter.parker@spiderman.com' => 'email', // true
```

#### phone

[](#phone)

Validates a valid 7, 10, 11 digit phone number (North America, Europe and most Asian and Middle East countries), supporting country and area codes (in dot, space or dashed notations) such as:

```
    '(555)555-5555' => 'phone', // true
    // other phone numbers accepted
    (555)555-5555
    555 555 5555
    +5(555)555.5555
    33(1)22 22 22 22
    +33(1)22 22 22 22
    +33(020)7777 7777
    03-6106666
```

#### postalCode

[](#postalcode)

Validates a postal code according to the given country code.

```
   '75000' => 'postalCode:FR', // true
   '02179000' => 'postalCode:BR', // true
   '02179-000' => 'postalCode:BR', // true
   '02179-000' => 'postalCode:US', // false
   '55372' => 'postalCode:US', // true
```

#### equal

[](#equal)

Validates if the input is equal to some value.

```
    'Peter Parker' => 'equal:Peter Parker', // true
    // you can pass php function to check a value like this :
    'password' => 'equal:password_verify,your_password',
    'password' => 'equal:md5,your_password',
```

#### values

[](#values)

Validates if the input contains one of the following values.

```
    'Peter' => 'values:Peter,Parker,Spiderman', // true
    'Peter' => 'values:Parker,Spiderman', // false
```

#### same

[](#same)

Validates if the input is equal to another input.

```
    // for $_POST and $_GET validation
    // firstName = Peter
    'firstName' => 'alpha', // true
    // lastName = Peter
    'lastName' => 'same:firstName', // true
```

#### length

[](#length)

Validates lengths.

```
    'Peter' => 'length:5', // true
    'Peter' => 'length:>4', // true
    'Peter' => 'length: 'mimes:jpg', // true
```

#### size

[](#size)

Validates file sizes:

```
    // size in octet
    'image.jpg' => 'size:10000', // true
    'image.jpg' => 'size:10000', // true
    'image.jpg' => 'size:10000,20000', // true
```

#### height &amp; width

[](#height--width)

Validates image height or width:

```
    // height and width in px
    'image.jpg' => 'height:200|width:200', // true
    'image.jpg' => 'height:200|width:>200', // true
    'image.jpg' => 'height:200,300|width:200,300', // true
```

#### set

[](#set)

Validates if the input is set.

```
    // for $_POST & $_GET
    'firstName' => 'set', // true
    // php : if(isset($_POST['firstName'])) or if(isset($_GET['firstName']))
```

#### required

[](#required)

Check if the input is set and not empty

```
    // for $_POST & $_GET
    'firstName' => 'required', // true
```

#### requiredIf

[](#requiredif)

The field is required if it validates some condition

```
    // for $_POST & $_GET
    'firstName' => 'required', // true

    // lastName is required if value1 is equal to value2
    'lastName' => 'requiredIf:value1,value2',

    // lastName is required if firstName is set and not empty
    'lastName => 'requiredIf:field,firstName',

    // lastName is required if firstName is set and empty
    'lastName' => 'requiredIf:empty_field,firstName',

    // lastName is required if firstName is set
    'lastName' => 'requiredIf:field_set,firstName',

    // lastName is required if firstName is not set
    'lastName' => 'requiredIf:field_not_set,firstName',

    // lastName is required if firstName value is equal to Peter
    'lastName' => 'requiredIf:field_value,firstName,Peter',

    // lastName is required if firstName value is not equal to Peter
    'lastName' => 'requiredIf:field_value_not,firstName,Peter',

```

#### requiredWith

[](#requiredwith)

The input is required with other inputs

```
    'firstName1::Peter|lastName1::Parker' => '',
    'firstName2::|lastName2::Parker' => '',

    // age is required with firstName and lastName
    'age1::20' => 'requiredWith:firstName1,lastName1',  // true
    'age2::20' => 'requiredWith:firstName2,lastName2',  // false firstName1 is empty
    'age3::' => 'requiredWith:firstName1,lastName1',  // false age is empty
```

#### requiredOneOf

[](#requiredoneof)

The input is required with one of the following inputs

```
    'firstName1::Peter|lastName1::Parker' => '',
    'firstName2::Peter|lastName2::' => '',
    'firstName3::|lastName3::' => '',

    // age is required with one of the following inputs
    'age1::20' => 'requiredOneOf:firstName1,lastName1',  // true
    'age2::20' => 'requiredOneOf:firstName2,lastName2',  // true
    'age3::20' => 'requiredOneOf:firstName3,lastName3',  // false firstName3 or lastName3 must not be empty
    'age4::'   => 'requiredOneOf:firstName1,lastName1',  // false age is required
```

#### with

[](#with)

The input is optional but the followings inputs must not be empty

```
    'firstName1::Peter|lastName1::Parker' => '',
    'firstName2::Peter|lastName2::' => '',

    // age is optional but the followings input must not be empty
    'age1::20' => 'with:firstName1,lastName1', // true
    'age1::'   => 'with:firstName1,lastName1', // true
    'age2::20' => 'with:firstName2,lastName2', // false
```

#### oneOf

[](#oneof)

The input is optional but one of the following input must not be empty

```
    'firstName1::Peter|lastName1::Parker' => '',
    'firstName2::|lastName2::' => '',

    // age is optional but one of the following input must not be empty
    'age1::20' => 'with:firstName1,lastName1', // true
    'age1::'   => 'with:firstName1,lastName1', // true
    'age2::20' => 'with:firstName2,lastName2', // false
```

#### optional

[](#optional)

The input is optional and the following rules are not executed if the input is empty

```
    'firstName::' => 'optional|alpha|length: 'optionalIf:field,firstName',

    // lastName is optional if firstName is set and empty
    'lastName' => 'optionalIf:empty_field,firstName',

    // lastName is optional if firstName is set
    'lastName' => 'optionalIf:field_set,firstName',

    // lastName is optional if firstName is not set
    'lastName' => 'optionalIf:field_not_set,firstName',

    // lastName is optional if firstName value is equal to Peter
    'lastName' => 'optionalIf:field_value,firstName,Peter',

    // lastName is optional if firstName value is not equal to Peter
    'lastName' => 'optionalIf:field_value_not,firstName,Peter',
```

#### skipIf

[](#skipif)

Skip the input rules if it valid some condition

```
    'firstName::Peter' => '',

    // skip lastName if value1 is equal to value2
    'lastName' => 'skipIf:value1,value2',

    // skip lastName  if firstName is set and not empty
    'lastName => 'skipIf:field,firstName',

    // skip lastName  if firstName is set and empty
    'lastName' => 'skipIf:empty_field,firstName',

    // skip lastName  if firstName is set
    'lastName' => 'skipIf:field_set,firstName',

    // skip lastName  if firstName is not set
    'lastName' => 'skipIf:field_not_set,firstName',

    // skip lastName  if firstName value is equal to Peter
    'lastName' => 'skipIf:field_value,firstName,Peter',

    // skip lastName  if firstName value is not equal to Peter
    'lastName' => 'skipIf:field_value_not,firstName,Peter',
```

### Assignation

[](#assignation)

#### add

[](#add)

```
     'name1::Peter' => 'add:end,Parker', // name1 = Peter Parker
     'name2::Parker' => 'add:begin,Peter', // name2 = Peter Parker
```

#### assign

[](#assign)

```
     // you can modify your input value with a crypt function
     'password::Peter' => 'assign:crypt,password_hash', // password = password_hash('Peter', PASSWORD_BCRYPT);
     // you can use other crypt function like md5, sha5 ..

     // change your input value
     'name::Parker' => 'assign:Peter', // name = Peter
     // or
     'name::Parker' => 'assign:value,Peter', // name = Peter

     // change your input value with another input value
     'firstName::Peter' => '',
     'lastName::Parker' => 'assign:field,firstName', // lastName = Peter

     // assign the file name to file input
     'file' => 'assign:file'

     // assign this input value to another input
     'firstName::Peter' => '',
     'lastName::Parker' => 'assign:this,firstName', // firstName = Parker

```

### License

[](#license)

The JetFire Validator is released under the MIT public license : .

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

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://www.gravatar.com/avatar/7b1f2a3db41601a0dd4b4bd774cf48673b6cd3c2208062b4a6f1b7697a817c3f?d=identicon)[jetfirephp](/maintainers/jetfirephp)

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/jetfirephp-validator/health.svg)](https://phpackages.com/packages/jetfirephp-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)
