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

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

alexpts/simple-validator
========================

Simple validate request data

1.1.0(8y ago)0148MITPHPPHP ^7.1

Since Sep 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/alexpts/simple-validator)[ Packagist](https://packagist.org/packages/alexpts/simple-validator)[ Docs](https://github.com/alexpts/simple-validator)[ RSS](/packages/alexpts-simple-validator/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

simple-validator
================

[](#simple-validator)

[![SensioLabsInsight](https://camo.githubusercontent.com/c913cec3b5b37c45989d12b53e2d9fc4bf300c2bfccaee7a1fdef67ffeff5fb3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f64653034303764392d313266652d346433642d613638382d3962323962313061306534362f6269672e706e67)](https://insight.sensiolabs.com/projects/de0407d9-12fe-4d3d-a688-9b29b10a0e46)

[![Build Status](https://camo.githubusercontent.com/dd55dc7f0300026e29eeb70c0277d29c071f0ee9c69c646534c1baae3e0d66f8/68747470733a2f2f7472617669732d63692e6f72672f616c65787074732f73696d706c652d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alexpts/simple-validator)[![Code Coverage](https://camo.githubusercontent.com/2d54ed6c8f020f27683748f32655309f34d30ecda80c94b47d90a357e2726e48/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65787074732f73696d706c652d76616c696461746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alexpts/simple-validator/?branch=master)[![Code Climate](https://camo.githubusercontent.com/2d3354b7ce1574f17283d4444bb6ce1bb0c607052fce637348d3791e2e2bb263/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616c65787074732f73696d706c652d76616c696461746f722f6261646765732f6770612e737667)](https://codeclimate.com/github/alexpts/simple-validator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/184f904c1ae2e4ed30ed6a62a9c645e8af36ac3d54c546641083a4850d104fc7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65787074732f73696d706c652d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alexpts/simple-validator/?branch=master)

Simple validator for validate accos arrays.

#### Install

[](#install)

`composer require alexpts/simple-validator`

#### Example

[](#example)

```
$body = (array)$this->request->getParsedBody();

$validator = new Validator;

// shot format
$errors = $validator->validate($body, [
    'parentId' => ['int', 'betweenInt:0:99999'],
    'name' => ['string', 'min:3'],
    'slug' => ['string', 'min:3', 'max:120'],
    'sort' => ['int']
]);

// full format
$errors = $validator->validate($body, [
    'parentId' => ['int', ['betweenInt' => [0, 99999]] ],
    'name' => ['string', ['min' => [3]] ],
    'slug' => ['string', ['min' => [3]], ['max' => [120]] ],
    'sort' => ['int']
]);

// validate if exists
$errors = $validator->validateIfExists($body, [
    'name' => ['string', ['min' => [3]] ],
    'sort' => ['int'] // field not passed, not validate
]);

// deep attributes
$errors = $validator->validate($body, [
    'user' => ['array', 'min:3'],
    'user.name' => ['string', 'min:3'],
    'user.age' => ['int'],
]);

$errors = $validator->validateIfExists($body, [
    'user' => ['array', 'min:3'],
    'user.name' => ['string', 'min:3'],
    'user.age' => ['int'],
]);
```

#### Validators:

[](#validators)

##### string

[](#string)

The field under validation must be string

##### int

[](#int)

The field under validation must be integer

##### float

[](#float)

The field under validation must be float

##### array

[](#array)

The field under validation must be array

##### required

[](#required)

Required field

##### betweenInt:min:max

[](#betweenintminmax)

Int from range \[min, max\]

##### betweenFloat:min:max

[](#betweenfloatminmax)

Float from range \[min, max\]

##### bool

[](#bool)

The field under validation must be boolean

##### alpha

[](#alpha)

The field under validation must be entirely alphabetic characters

##### alphaDash

[](#alphadash)

The field under validation may have alpha-numeric characters, as well as dashes and underscores

##### alphaNum

[](#alphanum)

The field under validation must be entirely alpha-numeric characters

##### date

[](#date)

The field under validation must be a valid date according to the strtotime PHP function

##### dateTime

[](#datetime)

Value instance of \\DateTime object

##### inArray

[](#inarray)

Check value in array

##### min

[](#min)

Min length fot string, min value for number, min count for array

##### max

[](#max)

Max length fot string, max value for number, max count for array

##### email

[](#email)

The field under validation must be simple email string

#### Custom validator

[](#custom-validator)

You can add custom validator via method

```
public function registerRule(string $name, callable $handler): self
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

3034d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31106536118e11bf9d0c9d7f467db5b534efa9c46ee76680b308f0c39d9a798c?d=identicon)[alexpts](/maintainers/alexpts)

---

Top Contributors

[![alexpts](https://avatars.githubusercontent.com/u/1306916?v=4)](https://github.com/alexpts "alexpts (31 commits)")

---

Tags

phpvalidationvalidatorvalidatorvalidate

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[wixel/gump

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

1.2k1.4M31](/packages/wixel-gump)[sadegh19b/laravel-persian-validation

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

18596.0k1](/packages/sadegh19b-laravel-persian-validation)[awurth/slim-validation

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

65393.6k9](/packages/awurth-slim-validation)[romeoz/rock-validate

Flexible validator for PHP with I18N.

251.7k6](/packages/romeoz-rock-validate)

PHPackages © 2026

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