PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Tom Schaefer   Input Validator   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: interface error sample
Class: Input Validator
Validate of nested arrays using XML schema rules
Author: By
Last change:
Date: 11 years ago
Size: 1,129 bytes
 

Contents

Class file image Download
<?php

  
// this sample has an error caused by a wrong interface

  
include_once 'InputValidator.php';


   interface
testInterface {}
   class
Alpha implements testInterface{}
   class
Beta{}

 
 
$definition = array(
     
"data" => array(
       
"is_active" => false,
       
"name" => "Thomas",
       
"firstname" => "Schaefer",
       
"born_at" => "2012-05-23",
       
"gender" => 1,
       
"address" => array(
         
"city" => "Erftstadt",
         
"zip" => 50374
       
),
       
"myObject" => new Alpha
     
)
  );
 
 
$data = array(
         
"data" => array(
           
"is_active" => "1",
           
"name" => "asd",
           
"firstname" => "Schaefer",
           
"born_at" => "2012-05-23",
           
"gender" => "1",
           
"address" => array(
             
"city" => "Erftstadt",
             
"zip" => "50374"
           
),
           
"myObject" => new Beta
         
)
      );
   

 
$check = new InputValidator();
 
$check->execute($data, $definition);

 
  if(
$check->hasError()){
   
print_r($check->getError());
  }