From 5afb6eeef7f496e8bc42ac53cefac483f951cc9e Mon Sep 17 00:00:00 2001 From: PJZ9n <38120936+PJZ9n@users.noreply.github.com> Date: Sat, 9 Jul 2022 07:57:53 +0900 Subject: [PATCH] Slider: Add validation considering steps --- src/dktapps/pmforms/element/Slider.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dktapps/pmforms/element/Slider.php b/src/dktapps/pmforms/element/Slider.php index 8914c16..9fb5005 100644 --- a/src/dktapps/pmforms/element/Slider.php +++ b/src/dktapps/pmforms/element/Slider.php @@ -74,6 +74,9 @@ public function validateValue($value) : void{ if($value < $this->min or $value > $this->max){ throw new FormValidationException("Value $value is out of bounds (min $this->min, max $this->max)"); } + if($value !== 0 and fmod((float)$value, $this->step) !== (float)0){//do not use % operator + throw new FormValidationException("Value $value is not divisible by step ($this->step)"); + } } public function getMin() : float{