From 90944dd5415e020e37f532cf58e132eb9df33a25 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 12 May 2020 19:26:07 +0200 Subject: [PATCH] LSformRule_integer: fix handle min/max parameters and add debug --- src/includes/class/class.LSformRule_integer.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/includes/class/class.LSformRule_integer.php b/src/includes/class/class.LSformRule_integer.php index 1d98b469..e6e442db 100644 --- a/src/includes/class/class.LSformRule_integer.php +++ b/src/includes/class/class.LSformRule_integer.php @@ -42,12 +42,16 @@ class LSformRule_integer extends LSformRule{ */ public static function validate ($value,$options=array(),$formElement) { $max = LSconfig :: get('params.max', null, 'int', $options); - if(is_int($max) && $value > $max) + if(is_int($max) && $max != 0 && $value > $max) { + self :: log_debug("value is too higth ($value > $max)"); return; + } $min = LSconfig :: get('params.min', null, 'int', $options); - if(is_int($min) && $value < $min) + if(is_int($min) && $min != 0 && $value < $min) { + self :: log_debug("value is too low ($value < $min)"); return; + } if(LSconfig :: get('params.negative', false, 'bool', $options)) { $regex = '/^-[0-9]*$/'; @@ -59,7 +63,11 @@ class LSformRule_integer extends LSformRule{ $regex = '/^-?[0-9]*$/'; } LSsession :: loadLSclass('LSformRule_regex'); - return LSformRule_regex :: validate($value,$regex,$formElement); + if (!LSformRule_regex :: validate($value,$regex,$formElement)) { + self :: log_debug("value '$value' does not respect regex '$regex'"); + return; + } + return true; } }