From 1b1ab6a66eb859f0e1232872a096620bef70df87 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Thu, 17 Aug 2017 18:52:17 +0200 Subject: [PATCH] [validation] Fix error on undefined optional numeric value Providing no value for an optional numeric parameter results in error "Parameter *** is invalid!" This is caused by the validation function ignoring the 'required' attribute when loading and checking input parameters. This commit adds checks to determine whether the 'required' attri- bute is defined and active before returning the error message. References #570: --- lib/validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/validation.php b/lib/validation.php index e405b7c..fdcb51c 100644 --- a/lib/validation.php +++ b/lib/validation.php @@ -80,7 +80,7 @@ function validateData(&$data, $parameters){ break; } - if(is_null($data[$name])) { + if(is_null($data[$name]) && isset($set[$name]['required']) && $set[$name]['required']) { echo 'Parameter \'' . $name . '\' is invalid!' . PHP_EOL; return false; }