Zend_Validate_StringLength::isValid PHP Méthode

isValid() public méthode

Returns true if and only if the string length of $value is at least the min option and no greater than the max option (when the max option is not null).
public isValid ( string $value ) : boolean
$value string
Résultat boolean
    public function isValid($value)
    {
        if (!is_string($value)) {
            $this->_error(self::INVALID);
            return false;
        }
        $this->_setValue($value);
        if ($this->_encoding !== null) {
            $length = iconv_strlen($value, $this->_encoding);
        } else {
            $length = iconv_strlen($value);
        }
        if ($length < $this->_min) {
            $this->_error(self::TOO_SHORT);
        }
        if (null !== $this->_max && $this->_max < $length) {
            $this->_error(self::TOO_LONG);
        }
        if (count($this->_messages)) {
            return false;
        } else {
            return true;
        }
    }

Usage Example

Exemple #1
0
 public function updateGroupsRows($text, $id, $sportId)
 {
     if ($this->conn->checkAdmin()) {
         $int = new Zend_Validate_Int();
         if (!$int->isValid($id)) {
             return $this->test;
         }
         if (!$int->isValid($sportId)) {
             return $this->test;
         }
         $validator = new Zend_Validate_StringLength(2, 100);
         if (!$validator->isValid($text)) {
             return $this->test;
         }
         $query = "CALL updateGroups('" . $text . "','" . $id . "');";
         $result = $this->conn->insert($query);
         $query = "CALL selectGroups( '" . $sportId . "');CALL selectSports( )";
         $result->message = $this->conn->multiresultbackArray($query);
         return $result;
     } else {
         $this->test->type = "error";
         $this->test->info = "nologin";
         return $this->test;
     }
 }
All Usage Examples Of Zend_Validate_StringLength::isValid