Validating and filtering Zend forms without Zend forms

Is there a way to test and filter clean HTML forms using the Zend Validation and Zend Filter classes? Please give an example, if you have, I could not find out.

+4
source share
1 answer
$email = $this->_getParam('email');// form $_POST or $_GET $email_validator = new Zend_Validate_EmailAddress(); if(!$email_validator->isValid($email)){ // Error, throw(Exception) } 

To find out which check you can use, open the library folder and go to library / Zend / Validate / path, you will see many files / classes. These are available classes for checking, such as Alnum.php, Alpha.php, Barcode.php, CreditCard.php, etc. Just create an instance and call method isValid ();

 new Zend_Validate_FileName(); 

The same for filters, in the path library / Zend / Filter / you can see many classes. Almost all of them implement the Zend_Filter_Interface (Interface.php) interface, where you can find one method:

 public function filter($value); 
+4
source

All Articles