PHP Classes

rbardin@gmail.com

Recommend this page to a friend!

      php Singleton Validator And Sanitizor Class  >  All threads  >  rbardin@gmail.com  >  (Un) Subscribe thread alerts  
Subject:rbardin@gmail.com
Summary:Singleton Validator And Sanitizor Class
Messages:3
Author:Rodolfo Bardin
Date:2014-12-15 11:49:08
 

 


  1. rbardin@gmail.com   Reply   Report abuse  
Picture of Rodolfo Bardin Rodolfo Bardin - 2014-12-15 11:49:08
Please could post an example of using this library.
Thank you

  2. Re: rbardin@gmail.com   Reply   Report abuse  
Picture of Anirban Nath Anirban Nath - 2014-12-16 05:41:21 - In reply to message 1 from Rodolfo Bardin
HI rbardin,

//Example usage,

//Multiple POST or GET values(eg While submitting Form)

$request = Request::getInstance(); //initialize or call singleton class

#OUTPUT ::

echo '<pre>';

print_r($request->validate($_GET,$rules));

//SIngle value validate or sanitize or both

$singleValue = 'Anything'; //$_POST['sumthing'];

//OUTPUT ::

print_r($request->validate($singleValue,array('REQUIRED' => true,'VALIDATE' =>'ALPHA', 'SANITIZE'=> 'STRING'),true));

echo '</pre>';

  3. Re: rbardin@gmail.com   Reply   Report abuse  
Picture of Anirban Nath Anirban Nath - 2014-12-16 05:43:47 - In reply to message 1 from Rodolfo Bardin
HI rbardin,

//Example usage,

//Multiple POST or GET values(eg While submitting Form)

$request = Request::getInstance(); //initialize or call singleton class

$rules = array( 'METHOD' => 'GET',
'REQUIRED' => array('name','email') ,
'SANITIZE' => array('name' =>'STRING','email' => 'EMAIL'),
'VALIDATE' => array('name' =>'ALPHA', 'email' => 'EMAIL'),
); //RULES should be defined based on your requirements




#OUTPUT ::

echo '<pre>';

print_r($request->validate($_GET,$rules));



//---------Single value validate or sanitize or both-----------

$singleValue = 'Anything'; //$_POST['sumthing'];

//OUTPUT ::

print_r($request->validate($singleValue,array('REQUIRED' => true,'VALIDATE' =>'ALPHA', 'SANITIZE'=> 'STRING'),true));

echo '</pre>';