min = false; $this->max = false; if (is_numeric($params)) { $params = ['max' => $params]; } elseif (is_array($params) && count($params) === 2 && isset($params[0]) && isset($params[1])) { $params = ['min' => min($params), 'max' => max($params)]; } return $params; } public function check(&$value) { if (! is_string($value)) { if (is_array($value)) { foreach ($value as $element) { if (! is_string($element)) { return false; } elseif (! $this->check($element)) { return false; } } return true; } return false; } $length = mb_strlen($value); if ($this->max !== false && $length > $this->max) { $this->replace['max'] = tpl::declension($this->max, _t('', 'symbol;symbols;symbols')); $this->setMessage(_t('error', 'The [attribute] must be [max] or less'), false); return false; } if ($this->min !== false && $length < $this->min) { $this->replace['min'] = tpl::declension($this->min, _t('', 'symbol;symbols;symbols')); $this->setMessage(_t('error', 'The [attribute] must be [min] or more'), false); return false; } return true; } }