Created
March 9, 2011 16:05
-
-
Save alganet/862460 to your computer and use it in GitHub Desktop.
Exemplo de integração do Respect com Zend 1.x usando closures
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 | |
use Respect\Validation\Validator as v; | |
//Enclosurer | |
function zv($name, $arguments) { | |
$name = ucfirst($name); | |
$validatorName = "Zend_Validate_$name"; | |
$validator = new $validatorName($arguments); | |
return new v::callback(function($input) use ($validator) { | |
return $validator->isValid($input); | |
}); | |
} | |
//Exemplo. Valida um IP usando o Respect OU um hostname usando Zend 1.x | |
$result = v::oneOf( | |
v::ip(), | |
zv('hostname') | |
)->validate($value); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment