/** * 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)); } }
/** * @expectedException \InvalidArgumentException */ public function testThrowsAnExceptionWhenARuleIsNotAnInstanceOfParamRule() { f\validate_coll(array('a' => 1), array('a' => 'is_int')); }