Last active
August 29, 2015 14:04
-
-
Save humbertodosreis/64e848521e47c0b8970a to your computer and use it in GitHub Desktop.
Exemplo de validação e filtro de dados com ZF1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Application_Controller_Login { | |
public function indexAction() { | |
$nome = $this->getRequest()->getParam('nome'); | |
$validator = new Zend_Validate(); | |
$validator->addValidator(new Zend_Validate_Alpha()) | |
->addValidator(new Zend_Validate_NotEmpty()); | |
if($validator->isValid($nome)) { | |
$this->view->message = "Tudo certo!"; | |
} | |
$filter = new Zend_Filter(); | |
$filter->addFilter(new Zend_Filter_StringTrim()) | |
->addFilter(new Zend_Filter_StripTags()); | |
$nomeTratado = $filter->filter($nome); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment