Are you a PHP developer who feels like you get no respect? That’s exactly what Alexandre Gomes Gaigalas and Carlos A. Ferrari are offering with their GitHub organization.

Validation is billed as “the most awesome validation engine ever created for PHP.” While that might be the epitome of hyperbole, it is indeed nifty. Validation includes more than 30 chainable validators supporting composite validation of nested, grouped, and related rules.

Let’s look at a simple example:

use RespectValidationValidator as v;
v::numeric()->validate($someNumber); //returns true or false 

We did mention chaning, right?

//From 1 to 15 non-whitespace alphanumeric characters 
$username = 'alganet';
$validUsername = v::alnum()
                  ->noWhitespace()
                  ->length(1,15)
                  ->validate($username);

Validators are also reusable:

$idValidator = v::int()->positive();
$idValidator->validate(123); //true
$idValidator->validate(456); //true

Be sure and check the Readme for advanced usage. Also be sure and check out Respect’s other projects including:

  • Relational is a chainable abstraction for relational database queries
  • Daemon is a library for managing daemon systems using PHP
  • Stream is a lightweight, asynchronous, object-oriented layer for the great PHP stream API
  • Env is a lightweight, transparent, testable and awesome environment wrapper for PHP

[Source on GitHub]


Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.