Skip to content
Particle\Validator is a validation library with an extremely clean API which makes validation fun!
Branch: master
Clone or download
RobQuistNL and RickvdStaaij Fix issue with rusing validator rule NotEmpty and IsRequired (#192)
* Add testcase and fix bug for NotEmpty rule being reused

* Fix the same for Required rule
Latest commit 657c754 Jan 7, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Fix (#169) Dec 5, 2017
.gitattributes Added issue and PR github template Feb 23, 2016
.travis.yml Fix: No need to allow PHP7 failures anymore Jun 28, 2015 improvements (#156) Oct 16, 2016
composer.lock Updating YAML library to be PHP 5.4 compatible. Mar 16, 2016
mkdocs.yml Merge branch 'master' of into updat… May 31, 2015
phpunit.xml Fix: Simplify test bootstrapping Jul 7, 2016


Travis-CI Packagist Packagist downloads Scrutinizer Scrutinizer

Particle\Validator is a very small validation library, with the easiest and most usable API we could possibly create.


To easily include Particle\Validator into your project, install it via composer using the command line:

composer require particle/validator

Small usage example

use Particle\Validator\Validator;

$v = new Validator;

$v->required('user.first_name')->lengthBetween(2, 50)->alpha();
$v->required('user.last_name')->lengthBetween(2, 50)->alpha();

$result = $v->validate([
    'user' => [
        'first_name' => 'John',
        'last_name' => 'D',
    'newsletter' => true,

$result->isValid(); // bool(false).
 * array(1) {
 *     ["user.last_name"]=> array(1) {
 *         ["Length::TOO_SHORT"]=> string(53) "last_name is too short and must be 2 characters long."
 *     }
 * }

Functional features

  • Validate an array of data
  • Get an array of error messages
  • Overwrite the default error messages on rules, or error messages on specific values
  • Get the validated values of an array
  • Validate different contexts (insert, update, etc.) inheriting validations of the default context
  • A large set of default validation rules
  • Ability to extend the validator to add your own custom rules

Non functional features

  • Easy to write (IDE auto-completion for easy development)
  • Easy to read (improves peer review)
  • Ability to separate controller and view logic
  • Fully documented:
  • Fully tested: Scrutinizer
  • Zero dependencies


Find more information and advanced usage examples at

You can’t perform that action at this time.