Ejemplo n.º 1
0
/**
 * f\validate_coll_or_throw($coll, $paramRules, $exceptionClass = 'Exception')
 *
 * Same than f\validate_coll but throws an exception if there is any error.
 */
function validate_coll_or_throw($coll, $paramRules, $exceptionClass = 'Exception')
{
    $errors = f\validate_coll($coll, $paramRules);
    if ($errors) {
        throw new $exceptionClass(json_encode($errors, true));
    }
}
Ejemplo n.º 2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testThrowsAnExceptionWhenARuleIsNotAnInstanceOfParamRule()
 {
     f\validate_coll(array('a' => 1), array('a' => 'is_int'));
 }