![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/Ecombricks/Framework/Validator/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See LICENSE.txt for license details. */ namespace Ecombricks\Framework\Validator; /** * String array validator */ class StringArrayValidator extends \Ecombricks\Framework\Validator\Validator { /** * Min length * * @var integer */ protected $minLength; /** * Max length * * @var integer */ protected $maxLength; /** * Constructor * * @param array $options * @return void */ public function __construct($options = []) { parent::__construct($options); if (!empty($options['min_length'])) { $this->setMinLength($options['min_length']); } if (!empty($options['max_length'])) { $this->setMaxLength($options['max_length']); } } /** * Get min length * * @return int */ public function getMinLength() { return $this->minLength; } /** * Set min length * * @param integer $minLength * @return $this */ public function setMinLength($minLength) { $this->minLength = $minLength; return $this; } /** * Get max length * * @return int */ public function getMaxLength() { return $this->maxLength; } /** * Set max length * * @param integer $maxLength * @return $this */ public function setMaxLength($maxLength) { $this->maxLength = $maxLength; return $this; } /** * Get array item validator * * @return bool */ public function getArrayItemValidator() { return new \Ecombricks\Framework\Validator\StringValidator([ 'label' => $this->getLabel(), 'required' => $this->getIsRequired(), 'min_length' => $this->getMinLength(), 'max_length' => $this->getMaxLength() ]); } /** * Add validators * * @param mixed $value * @return $this */ protected function addValidators($value) { parent::addValidators($value); $this->addArrayValidator($value); return $this; } }