2017 © Pedro Peláez
 

library validationwall

image

atillaordog/validationwall

  • Thursday, October 1, 2015
  • by atillaordog
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ValidationWall

A simple code that breaks down validation into small blocks, (*1)

The whole idea is to be able to build custom validation as if they were legos. A rule is a lego that can be used together with other rules to build a ruleset. A ruleset is used to check one field from the incoming data. A door on the wall can be built using rulesets. A door is the way trough the Wall, the whole data gets through it by using rulesets defined for every field., (*2)

How to use:, (*3)

include('ValidationWall/autoload.php');

// Before the class you need to define the uses
use ValidationWall;
use ValidationWall\RuleSet\PredefRuleset;
use ValidationWall\Door\PredefDoor;
use ValidationWall\Rule\NotEmpty;
use ValidationWall\Rule\Numeric;

// Build a ruleset using rules
$rulesets = array();
$rulesets[] = new PredefRuleset('input_field', array(new NotEmpty(), new Numeric()))

$door = new PredefDoor($rulesets);

$vw = new ValidationWall($door);

if ( $vw->pass($data) )
{
    // Validation passed
}
else
{
    // Validation failed
}

To pass a comparison variable, or another field from post for comparison, use the Rule's constructor as seen in predefined examples., (*4)

$rule = new MaxLength(255);

The Versions

01/10 2015

dev-master

9999999-dev

  Sources   Download