Commit 5a3f397b authored by jensschuppe's avatar jensschuppe

Pass the input type to validators for being able to validate normalized values

parent 2277666c
......@@ -240,7 +240,7 @@
// Check the validations on the input.
if (isset($params[$input['name']]) && $params[$input['name']] != "") {
foreach ($input['validators'] as $validator) {
if (!$validator['validator']->validate($params[$input['name']])) {
if (!$validator['validator']->validate($params[$input['name']], $inputType)) {
throw new \API_Exception($validator['validator']->getInvalidMessage() . ' (Parameter ' . $input['name'] . ')');
}
}
......
......@@ -45,7 +45,7 @@
* @param mixed $input
* @return bool
*/
abstract public function validate($input);
abstract public function validate($input, $inputType);
public function __construct() {
$this->configuration = new ConfigurationBag();
......
......@@ -34,7 +34,7 @@
* @param mixed $input
* @return bool
*/
public function validate($input) {
public function validate($input, $inputType) {
$pattern = EmailValidator::PATTERN_LOOSE;
return preg_match($pattern, $input);
}
......
......@@ -41,7 +41,7 @@
* @param mixed $input
* @return bool
*/
public function validate($input) {
public function validate($input, $inputType) {
return $input <= $this->configuration->get('max_value') ? true : false;
}
......
......@@ -33,7 +33,7 @@
* @param mixed $input
* @return bool
*/
public function validate($input) {
public function validate($input, $inputType) {
return strlen($input) >= $this->configuration->get('min_length') ? true : false;
}
......
......@@ -41,7 +41,7 @@
* @param mixed $input
* @return bool
*/
public function validate($input) {
public function validate($input, $inputType) {
return $input >= $this->configuration->get('min_value') ? true : false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment