From 723ea4f75084fe6a9bbc81810b7e4c09cc035174 Mon Sep 17 00:00:00 2001 From: coderkun Date: Tue, 8 Apr 2014 23:47:39 +0200 Subject: [PATCH] pass validation settings directly to method ?validation? of ValiadionComponent --- .../components/ValidationComponent.inc | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/controllers/components/ValidationComponent.inc b/controllers/components/ValidationComponent.inc index 8034e47d..dbe5b0b3 100644 --- a/controllers/components/ValidationComponent.inc +++ b/controllers/components/ValidationComponent.inc @@ -44,13 +44,12 @@ /** * Validate an user input. * - * @param mixed $input User input to validate - * @param string $name Name of the field to validate against - * @return mixed True or the settings the validation fails on + * @param mixed $input User input to validate + * @param array $settings Validation setting + * @return mixed True or the settings the validation fails on */ - public function validate($input, $name) + public function validate($input, $settings) { - $settings = $this->config[$name]; $validation = array(); // Min string length @@ -93,10 +92,13 @@ } // Check parameter - $param = $params[$index]; - $check = $this->validate($param, $index); - if($check !== true) { - $validation[$index] = $check; + if(array_key_exists($index, $this->config)) + { + $param = $params[$index]; + $check = $this->validate($param, $this->config[$index]); + if($check !== true) { + $validation[$index] = $check; + } } }