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/MaxLength.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 libs/SimpleValidator/Validators/MaxLength.php (limited to 'libs/SimpleValidator/Validators/MaxLength.php') diff --git a/libs/SimpleValidator/Validators/MaxLength.php b/libs/SimpleValidator/Validators/MaxLength.php new file mode 100644 index 00000000..6c4e7771 --- /dev/null +++ b/libs/SimpleValidator/Validators/MaxLength.php @@ -0,0 +1,24 @@ +max = $max; + } + + public function execute(array $data) + { + if ($this->isFieldNotEmpty($data)) { + $length = mb_strlen($data[$this->field], 'UTF-8'); + return $length <= $this->max; + } + + return true; + } +} -- cgit v1.2.3