Login   Register  
PHP Classes
elePHPant
Icontem

File: example_sequence.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mark Rolich  >  Data Validator  >  example_sequence.php  >  Download  
File: example_sequence.php
Role: Example script
Content type: text/plain
Description: Example of sequential validation order
Class: Data Validator
Validate a set of values based on a list of rules
Author: By
Last change:
Date: 2012-08-10 07:16
Size: 817 bytes
 

Contents

Class file image Download
<?php
include 'lib/DataValidatorLib.php';
include 
'lib/DataValidator.php';

$data = array(
    
'field1' => '',
    
'field2' => '',
    
'field3' => '',
    
'field4' => '',
    
'field5' => '',
    
'field6' => '',
    
'field7' => ''
);

$ruleset = array(
    
'field1.isEmpty' => 'Please enter field1',
    
'field2.isEmpty' => 'Please enter field2',
    
'field3.isEmpty' => 'Please enter field3',
    
'field4.isEmpty' => 'Please enter field4',
    
'field5.isEmpty' => 'Please enter field5',
    
'field6.isEmpty' => 'Please enter field6',
    
'field7.isEmpty' => 'Please enter field7'
);

$validator = new DataValidator();

$validator->setData($data);
$validator->setRuleset($ruleset);
$validator->setOrder(0);

$validator->validate();

$errors $validator->getErrors();

echo 
'<pre>';
print_r($errors);
echo 
'</pre>';
?>