Commit 9461bef4 authored by jensschuppe's avatar jensschuppe

Merge branch 'validator_input_type' into date_validator

parents 2277666c f8dfe4db
......@@ -5,6 +5,7 @@ Version 1.7 (not yet released)
* Fixed #11 Errors in DateType validation
* Added try out functionality.
* Added Min/Max validators.
* Now passing input type to input validators.
Version 1.6
===========
......
......@@ -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