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

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

frangeris/simple-validation
===========================

Simple, fast, beautiful way to make validations for forms or anything you can think of

v0.1.1(11y ago)4661[7 issues](https://github.com/frangeris/simple-validation/issues)MITPHPPHP &gt;=5.5.0

Since Feb 12Pushed 11y ago2 watchersCompare

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

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

Simple validation for PHP 5.5+
==============================

[](#simple-validation-for-php-55)

There are so many differents ways to make a validation for forms on php, each framework(Laravel 4+, Symfony 2+, CodeIgniter , FuelPHP, CakePHP, bla bla bla) has their own implementation on validations, ok, that's ok, it is expected that they supply us that funcionality, but, sometimes all those validations are complicated, sometimes we dont want to insert the rules inside a model when we just wanna validate a simple html form and get the possible failures, just simple like that, it ok that you insert your rules inside your model, this is another way just with super powers...

### Installation

[](#installation)

Easiest way would be using [Composer](http://getcomposer.org) and adding this to the composer.json requirement section.

```
{
  "require": {
    "frangeris/simple-validation": "dev-master"
  }
}
```

It's PSR-0 compliant, so you can also use your own custom autoloader.

### Usage

[](#usage)

In general, every form could have **rules**, what is a rule?, rule is just what you want to validate, just like that, here is the list of rules we support:

- regex (for regular expression purposes)
- min (validate that is upper than)
- max (validate that don't exced a number)
- required (validate that the value is not null or empty)
- filter ([php native filter](http://www.php.net/manual/en/filter.filters.php) :D)
- uploaded (validate that the file has been uploaded)
- file\_max (validate the max size of the file using MB for comparation)
- allow\_format (specify with formats are allowed for the file uploaded)
- not\_equal (verify that the value is not equal to expressed pattern)

### So let's rock and roll:

[](#so-lets-rock-and-roll)

Here is an example of the structure for write your own validations, in this case I wanna validate a form for just save users over 18 years old, and of course a valid first name, last name and email.

```

```

file with rules:

```
