yamcsha

#Zend - validate input

Apr 17th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2. if ($this->_request->isPost()) {
  3.     $filters = array(
  4.         'x'  => array('HtmlEntities', 'StripTags', 'StringTrim'),
  5.         'y'  => array('HtmlEntities', 'StripTags', 'StringTrim')
  6.     );             
  7.     $validators = array(
  8.     'x'      => array('NotEmpty', 'Int'),
  9.     'y'      => array(
  10.             'Alpha',
  11.             array('InArray', 'haystack' => array('Title', 'Date'))
  12.             );
  13.                    
  14.     // validate inputs
  15.     $input = new Zend_Filter_Input ($filters, $validators);
  16.     $input->setData($this->_request->getpost());
  17.  
  18.     if ($input->isValid()) {
  19.         //
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment