From a4642d17e0e1ea018b128efdcc3db281461458b1 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 4 Apr 2018 15:21:13 -0700 Subject: Move custom libs to the source tree --- libs/SimpleValidator/Validators/Range.php | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libs/SimpleValidator/Validators/Range.php (limited to 'libs/SimpleValidator/Validators/Range.php') diff --git a/libs/SimpleValidator/Validators/Range.php b/libs/SimpleValidator/Validators/Range.php new file mode 100644 index 00000000..065b2b9d --- /dev/null +++ b/libs/SimpleValidator/Validators/Range.php @@ -0,0 +1,33 @@ +min = $min; + $this->max = $max; + } + + public function execute(array $data) + { + if ($this->isFieldNotEmpty($data)) { + + if (! is_numeric($data[$this->field])) { + return false; + } + + if ($data[$this->field] < $this->min || $data[$this->field] > $this->max) { + return false; + } + } + + return true; + } +} -- cgit v1.2.3