PHP Classes

File: error_sample.php

Recommend this page to a friend!
  Classes of Tom Schaefer   Input Validator   error_sample.php   Download  
File: error_sample.php
Role: Example script
Content type: text/plain
Description: error: wrong type, expecting boolean, receiving integer
Class: Input Validator
Validate of nested arrays using XML schema rules
Author: By
Last change:
Date: 12 years ago
Size: 1,115 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 = '{
      "data" : {
        "is_active" : false,
        "name" : "Thomas",
        "firstname" : "Schaefer",
        "born_at" : "2012-05-23",
        "gender" : 1,
        "address" : {
          "city" : "Erftstadt",
          "zip" : 50374
        }
      }
}'
;
 
 
$data = array(
         
"data" => array(
           
"is_active" => "3",
           
"name" => "asd",
           
"firstname" => "Schaefer",
           
"born_at" => "2012-05-23",
           
"gender" => "1",
           
"address" => array(
             
"city" => "Erftstadt",
             
"zip" => "50374"
           
),
          )
      );
   

 
$check = new InputValidator();
 
$check->execute($data, InputValidator::createXSDFromJSON("test", "./", $definition));

 
  if(
$check->hasError()){
   
print_r($check->getError());
  } else {
    echo
"valid";
  }