Created
January 31, 2012 00:32
-
-
Save filhodanuvem/1707824 to your computer and use it in GitHub Desktop.
Testando se uma regra existe no Respect\Validation
This file contains hidden or 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 | |
// A ideia é descobrir se a regra existe | |
// ex: $p['validate'] == 'image' | |
// Usei a SplClassLoader para carregar o Respect, porém, acho que na hora da biblioteca instanciar uma | |
// regra via Reflection, o autoload dá require num arquivo que nao existe, gerando um erro fatal | |
// ou seja, que não é capturado pelo try...catch. | |
use Respect\Validation as v; | |
$validator = new v\Validator(); | |
try{ | |
$validator = $validator->buildRule($p['validate']); | |
}catch(Exception $e){ | |
// ação específica. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment