Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

If $err is false, then validator functions return a bool

  • Loading branch information...
commit 04ca1f651c24e93e454b63864c6778b08ec1b237 1 parent b5b4eb5
@chriso authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 klein.php
View
13 klein.php
@@ -493,6 +493,8 @@ function addValidator($method, $callback) {
_Validator::$_methods[strtolower($method)] = $callback;
}
+class ValidatorException extends Exception {}
+
class _Validator {
public static $_methods = array();
@@ -580,9 +582,16 @@ public function __call($method, $args) {
default: $result = call_user_func_array($validator, $args); break;
}
+ $result = (bool)$result ^ $reverse;
+
+ //if $err is false just return the result as a bool
+ if (false === $this->_err) {
+ return $result
+ }
+
//Throw an exception on failed validation
- if (false === (bool)$result ^ $reverse) {
- throw new Exception($this->_err);
+ if (false === $result) {
+ throw new ValidatorException($this->_err);
}
return $this;
}
Please sign in to comment.
Something went wrong with that request. Please try again.