import v1.1.0_RC2 | 2009-09-20

This commit is contained in:
2019-07-17 22:19:00 +02:00
parent 3b7ba80568
commit 38c146901c
2504 changed files with 101817 additions and 62316 deletions

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 14317 2009-03-13 20:39:31Z thomas $
* @version $Id: Abstract.php 16223 2009-06-21 20:04:53Z thomas $
*/
/**
@ -27,7 +27,7 @@ require_once 'Zend/Validate/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
@ -93,6 +93,13 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
*/
protected $_translatorDisabled = false;
/**
* Limits the maximum returned length of a error message
*
* @var Integer
*/
protected static $_messageLength = -1;
/**
* Returns array of validation failure messages
*
@ -229,6 +236,12 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
foreach ($this->_messageVariables as $ident => $property) {
$message = str_replace("%$ident%", (string) $this->$property, $message);
}
$length = self::getMessageLength();
if (($length > -1) && (strlen($message) > $length)) {
$message = substr($message, 0, (self::getMessageLength() - 3)) . '...';
}
return $message;
}
@ -395,4 +408,24 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
{
return $this->_translatorDisabled;
}
/**
* Returns the maximum allowed message length
*
* @return integer
*/
public static function getMessageLength()
{
return self::$_messageLength;
}
/**
* Sets the maximum allowed message length
*
* @param integer $length
*/
public static function setMessageLength($length = -1)
{
self::$_messageLength = $length;
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Alnum.php 14560 2009-03-31 14:41:22Z thomas $
* @version $Id: Alnum.php 17467 2009-08-08 18:06:55Z thomas $
*/
/**
@ -27,19 +27,13 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Alnum extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value contains non-alphabetic or non-digit characters
*/
const NOT_ALNUM = 'notAlnum';
/**
* Validation failure message key for when the value is an empty string
*/
const INVALID = 'alnumInvalid';
const NOT_ALNUM = 'notAlnum';
const STRING_EMPTY = 'stringEmpty';
/**
@ -63,6 +57,7 @@ class Zend_Validate_Alnum extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be float, string, or integer",
self::NOT_ALNUM => "'%value%' has not only alphabetic and digit characters",
self::STRING_EMPTY => "'%value%' is an empty string"
);
@ -110,11 +105,14 @@ class Zend_Validate_Alnum extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value) && !is_int($value) && !is_float($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue($value);
if ('' === $valueString) {
if ('' === $value) {
$this->_error(self::STRING_EMPTY);
return false;
}
@ -129,7 +127,7 @@ class Zend_Validate_Alnum extends Zend_Validate_Abstract
self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;
if ($valueString !== self::$_filter->filter($valueString)) {
if ($value != self::$_filter->filter($value)) {
$this->_error(self::NOT_ALNUM);
return false;
}

View File

@ -1,5 +1,4 @@
<?php
/**
* Zend Framework
*
@ -15,34 +14,26 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Alpha.php 14560 2009-03-31 14:41:22Z thomas $
* @version $Id: Alpha.php 16223 2009-06-21 20:04:53Z thomas $
*/
/**
* @see Zend_Validate_Abstract
*/
require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Alpha extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value contains non-alphabetic characters
*/
const NOT_ALPHA = 'notAlpha';
/**
* Validation failure message key for when the value is an empty string
*/
const INVALID = 'alphaInvalid';
const NOT_ALPHA = 'notAlpha';
const STRING_EMPTY = 'stringEmpty';
/**
@ -66,6 +57,7 @@ class Zend_Validate_Alpha extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be a string",
self::NOT_ALPHA => "'%value%' has not only alphabetic characters",
self::STRING_EMPTY => "'%value%' is an empty string"
);
@ -113,11 +105,14 @@ class Zend_Validate_Alpha extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue($value);
if ('' === $valueString) {
if ('' === $value) {
$this->_error(self::STRING_EMPTY);
return false;
}
@ -132,7 +127,7 @@ class Zend_Validate_Alpha extends Zend_Validate_Abstract
self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;
if ($valueString !== self::$_filter->filter($valueString)) {
if ($value !== self::$_filter->filter($value)) {
$this->_error(self::NOT_ALPHA);
return false;
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Barcode.php 14042 2009-02-10 22:39:34Z thomas $
* @version $Id: Barcode.php 16223 2009-06-21 20:04:53Z thomas $
*/
/**
@ -27,7 +27,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Barcode extends Zend_Validate_Abstract

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ean13.php 11791 2008-10-09 18:19:13Z andries $
* @version $Id: Ean13.php 16223 2009-06-21 20:04:53Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract
@ -74,20 +74,18 @@ class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract
*/
public function isValid($value)
{
if (false === ctype_digit($value)) {
if (!is_string($value) || !ctype_digit($value)) {
$this->_error(self::NOT_NUMERIC);
return false;
}
$valueString = (string) $value;
$this->_setValue($valueString);
if (strlen($valueString) !== 13) {
$this->_setValue($value);
if (strlen($value) !== 13) {
$this->_error(self::INVALID_LENGTH);
return false;
}
$barcode = strrev(substr($valueString, 0, -1));
$barcode = strrev(substr($value, 0, -1));
$oddSum = 0;
$evenSum = 0;
@ -102,7 +100,7 @@ class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract
$calculation = ($oddSum + $evenSum) % 10;
$checksum = ($calculation === 0) ? 0 : 10 - $calculation;
if ($valueString[12] != $checksum) {
if ($value[12] != $checksum) {
$this->_error(self::INVALID);
return false;
}

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: UpcA.php 8210 2008-02-20 14:09:05Z andries $
* @version $Id: UpcA.php 16223 2009-06-21 20:04:53Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Barcode_UpcA extends Zend_Validate_Abstract
@ -67,15 +67,18 @@ class Zend_Validate_Barcode_UpcA extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
$this->_setValue($valueString);
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
if (strlen($valueString) !== 12) {
$this->_setValue($value);
if (strlen($value) !== 12) {
$this->_error(self::INVALID_LENGTH);
return false;
}
$barcode = substr($valueString, 0, -1);
$barcode = substr($value, 0, -1);
$oddSum = 0;
$evenSum = 0;
@ -90,7 +93,7 @@ class Zend_Validate_Barcode_UpcA extends Zend_Validate_Abstract
$calculation = ($oddSum + $evenSum) % 10;
$checksum = ($calculation === 0) ? 0 : 10 - $calculation;
if ($valueString[11] != $checksum) {
if ($value[11] != $checksum) {
$this->_error(self::INVALID);
return false;
}

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Between.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Between.php 16223 2009-06-21 20:04:53Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Between extends Zend_Validate_Abstract

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ccnum.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Ccnum.php 16223 2009-06-21 20:04:53Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Ccnum extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Date.php 13371 2008-12-19 11:41:09Z thomas $
* @version $Id: Date.php 17696 2009-08-20 20:12:33Z thomas $
*/
/**
@ -27,24 +27,14 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Date extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value does not follow the YYYY-MM-DD format
*/
const NOT_YYYY_MM_DD = 'dateNotYYYY-MM-DD';
/**
* Validation failure message key for when the value does not appear to be a valid date
*/
const INVALID = 'dateInvalid';
/**
* Validation failure message key for when the value does not fit the given dateformat or locale
*/
const NOT_YYYY_MM_DD = 'dateNotYYYY-MM-DD';
const INVALID_DATE = 'dateInvalidDate';
const FALSEFORMAT = 'dateFalseFormat';
/**
@ -53,8 +43,9 @@ class Zend_Validate_Date extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be string, integer, array or Zend_Date",
self::NOT_YYYY_MM_DD => "'%value%' is not of the format YYYY-MM-DD",
self::INVALID => "'%value%' does not appear to be a valid date",
self::INVALID_DATE => "'%value%' does not appear to be a valid date",
self::FALSEFORMAT => "'%value%' does not fit given date format"
);
@ -82,6 +73,13 @@ class Zend_Validate_Date extends Zend_Validate_Abstract
public function __construct($format = null, $locale = null)
{
$this->setFormat($format);
if ($locale === null) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Locale')) {
$locale = Zend_Registry::get('Zend_Locale');
}
}
if ($locale !== null) {
$this->setLocale($locale);
}
@ -139,35 +137,40 @@ class Zend_Validate_Date extends Zend_Validate_Abstract
* If optional $format or $locale is set the date format is checked
* according to Zend_Date, see Zend_Date::isDate()
*
* @param string $value
* @param string|array|Zend_Date $value
* @return boolean
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value) && !is_int($value) && !is_float($value) &&
!is_array($value) && !($value instanceof Zend_Date)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue($value);
if (($this->_format !== null) or ($this->_locale !== null)) {
if (($this->_format !== null) || ($this->_locale !== null) || is_array($value) ||
$value instanceof Zend_Date) {
require_once 'Zend/Date.php';
if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) {
if ($this->_checkFormat($value) === false) {
$this->_error(self::FALSEFORMAT);
} else {
$this->_error(self::INVALID);
$this->_error(self::INVALID_DATE);
}
return false;
}
} else {
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $valueString)) {
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
$this->_error(self::NOT_YYYY_MM_DD);
return false;
}
list($year, $month, $day) = sscanf($valueString, '%d-%d-%d');
list($year, $month, $day) = sscanf($value, '%d-%d-%d');
if (!checkdate($month, $day, $year)) {
$this->_error(self::INVALID);
$this->_error(self::INVALID_DATE);
return false;
}
}

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Abstract.php 17160 2009-07-26 19:46:24Z bittarman $
*/
/**
@ -31,7 +31,7 @@ require_once 'Zend/Validate/Abstract.php';
* @category Zend
* @package Zend_Validate
* @uses Zend_Validate_Abstract
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
@ -47,7 +47,12 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
*/
protected $_messageTemplates = array(self::ERROR_NO_RECORD_FOUND => 'No record matching %value% was found',
self::ERROR_RECORD_FOUND => 'A record matching %value% was found');
/**
* @var string
*/
protected $_schema = null;
/**
* @var string
*/
@ -57,7 +62,7 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
* @var string
*/
protected $_field = '';
/**
* @var mixed
*/
@ -77,7 +82,7 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
* to define the where clause added to the sql.
* A database adapter may optionally be supplied to avoid using the registered default adapter.
*
* @param string $table The database table to validate against
* @param string||array $table The database table to validate against, or array with table and schema keys
* @param string $field The field to check for a match
* @param string||array $exclude An optional where clause or field/value pair to exclude from the query
* @param Zend_Db_Adapter_Abstract $adapter An optional database adapter to use.
@ -88,8 +93,15 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
$this->_adapter = $adapter;
}
$this->_exclude = $exclude;
$this->_table = (string) $table;
$this->_field = (string) $field;
if (is_array($table)) {
$this->_table = (isset($table['table'])) ? $table['table'] : '';
$this->_schema = (isset($table['schema'])) ? $table['schema'] : null;
} else {
$this->_table = (string) $table;
}
}
/**
@ -103,15 +115,19 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
/**
* Check for an adapter being defined. if not, fetch the default adapter.
*/
if($this->_adapter === null) {
if ($this->_adapter === null) {
$this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
if (null === $this->_adapter) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('No database adapter present');
}
}
/**
* Build select object
*/
$select = new Zend_Db_Select($this->_adapter);
$select->from($this->_table, array($this->_field))
$select->from($this->_table, array($this->_field), $this->_schema)
->where($this->_adapter->quoteIdentifier($this->_field).' = ?', $value);
if ($this->_exclude !== null) {
if (is_array($this->_exclude)) {

View File

@ -17,7 +17,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: NoRecordExists.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: RecordExists.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
@ -32,7 +32,7 @@ require_once 'Zend/Validate/Db/Abstract.php';
* @category Zend
* @package Zend_Validate
* @uses Zend_Validate_Db_Abstract
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Db_RecordExists extends Zend_Validate_Db_Abstract

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Digits.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Digits.php 16933 2009-07-21 20:24:35Z matthew $
*/
@ -30,20 +30,14 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Digits extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value contains non-digit characters
*/
const NOT_DIGITS = 'notDigits';
/**
* Validation failure message key for when the value is an empty string
*/
const NOT_DIGITS = 'notDigits';
const STRING_EMPTY = 'stringEmpty';
const INVALID = 'digitsInvalid';
/**
* Digits filter used for validation
@ -59,7 +53,8 @@ class Zend_Validate_Digits extends Zend_Validate_Abstract
*/
protected $_messageTemplates = array(
self::NOT_DIGITS => "'%value%' contains not only digit characters",
self::STRING_EMPTY => "'%value%' is an empty string"
self::STRING_EMPTY => "'%value%' is an empty string",
self::INVALID => "Invalid type given, value should be string, integer or float",
);
/**
@ -72,24 +67,24 @@ class Zend_Validate_Digits extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value) && !is_int($value) && !is_float($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue((string) $value);
if ('' === $valueString) {
if ('' === $this->_value) {
$this->_error(self::STRING_EMPTY);
return false;
}
if (null === self::$_filter) {
/**
* @see Zend_Filter_Digits
*/
require_once 'Zend/Filter/Digits.php';
self::$_filter = new Zend_Filter_Digits();
}
if ($valueString !== self::$_filter->filter($valueString)) {
if ($this->_value !== self::$_filter->filter($this->_value)) {
$this->_error(self::NOT_DIGITS);
return false;
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: EmailAddress.php 14560 2009-03-31 14:41:22Z thomas $
* @version $Id: EmailAddress.php 16223 2009-06-21 20:04:53Z thomas $
*/
/**
@ -32,12 +32,13 @@ require_once 'Zend/Validate/Hostname.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_EmailAddress extends Zend_Validate_Abstract
{
const INVALID = 'emailAddressInvalid';
const INVALID_FORMAT = 'emailAddressInvalidFormat';
const INVALID_HOSTNAME = 'emailAddressInvalidHostname';
const INVALID_MX_RECORD = 'emailAddressInvalidMxRecord';
const DOT_ATOM = 'emailAddressDotAtom';
@ -49,7 +50,8 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "'%value%' is not a valid email address in the basic format local-part@hostname",
self::INVALID => "Invalid type given, value should be a string",
self::INVALID_FORMAT => "'%value%' is not a valid email address in the basic format local-part@hostname",
self::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'",
self::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'",
self::DOT_ATOM => "'%localPart%' not matched against dot-atom format",
@ -169,16 +171,20 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$matches = array();
$length = true;
$this->_setValue($valueString);
$this->_setValue($value);
// Split email address up and disallow '..'
if ((strpos($valueString, '..') !== false) or
(!preg_match('/^(.+)@([^@]+)$/', $valueString, $matches))) {
$this->_error(self::INVALID);
if ((strpos($value, '..') !== false) or
(!preg_match('/^(.+)@([^@]+)$/', $value, $matches))) {
$this->_error(self::INVALID_FORMAT);
return false;
}

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Exception.php 16223 2009-06-21 20:04:53Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Exception.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Exception extends Zend_Exception

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Count.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Count extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Crc32.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Hash.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: ExcludeExtension.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Extension.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: ExcludeMimeType.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/MimeType.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Exists.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Exists extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Extension.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Extension extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: FilesSize.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Size.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Hash.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Hash extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: ImageSize.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: IsCompressed.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/MimeType.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: IsImage.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/MimeType.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Md5.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Hash.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: MimeType.php 17203 2009-07-27 19:37:18Z thomas $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
@ -228,19 +228,27 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
if ($file !== null) {
$mimefile = $this->getMagicFile();
if (class_exists('finfo', false) && ((!empty($mimefile)) or (defined('MAGIC')))) {
if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
if (!empty($mimefile)) {
$mime = new finfo(FILEINFO_MIME, $mimefile);
$mime = new finfo($const, $mimefile);
} else {
$mime = new finfo(FILEINFO_MIME);
$mime = new finfo($const);
}
if ($mime !== false) {
$this->_type = $mime->file($value);
}
$this->_type = $mime->file($value);
unset($mime);
} elseif (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) {
$this->_type = mime_content_type($value);
} else {
$this->_type = $file['type'];
}
if (empty($this->_type)) {
if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) {
$this->_type = mime_content_type($value);
} else {
$this->_type = $file['type'];
}
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: NotExists.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Exists.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Sha1.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Hash.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Size.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Size extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: Upload.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_Upload extends Zend_Validate_Abstract

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
* @version $Id: WordCount.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Count.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_File_WordCount extends Zend_Validate_File_Count

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Float.php 13375 2008-12-19 14:16:40Z thomas $
* @version $Id: Float.php 17470 2009-08-08 22:27:09Z thomas $
*/
/**
@ -32,18 +32,19 @@ require_once 'Zend/Locale/Format.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Float extends Zend_Validate_Abstract
{
const INVALID = 'floatInvalid';
const NOT_FLOAT = 'notFloat';
/**
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be float, string, or integer",
self::NOT_FLOAT => "'%value%' does not appear to be a float"
);
@ -56,7 +57,9 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
*/
public function __construct($locale = null)
{
$this->setLocale($locale);
if ($locale !== null) {
$this->setLocale($locale);
}
}
/**
@ -89,18 +92,33 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value) && !is_int($value) && !is_float($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue($value);
if ($this->_locale === null) {
$locale = localeconv();
$valueFiltered = str_replace($locale['thousands_sep'], '', (string) $value);
$valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered);
try {
if (!Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
$this->_error();
if (strval(floatval($valueFiltered)) != $valueFiltered) {
$this->_error(self::NOT_FLOAT);
return false;
}
} else {
try {
if (!Zend_Locale_Format::isFloat($value, array('locale' => 'en')) &&
!Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
$this->_error(self::NOT_FLOAT);
return false;
}
} catch (Zend_Locale_Exception $e) {
$this->_error(self::NOT_FLOAT);
return false;
}
} catch (Zend_Locale_Exception $e) {
$this->_error();
return false;
}
return true;

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GreaterThan.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: GreaterThan.php 17470 2009-08-08 22:27:09Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_GreaterThan extends Zend_Validate_Abstract
@ -105,7 +105,7 @@ class Zend_Validate_GreaterThan extends Zend_Validate_Abstract
$this->_setValue($value);
if ($this->_min >= $value) {
$this->_error();
$this->_error(self::NOT_GREATER);
return false;
}
return true;

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hex.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Hex.php 17470 2009-08-08 22:27:09Z thomas $
*/
@ -30,14 +30,12 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hex extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value contains characters other than hexadecimal digits
*/
const INVALID = 'hexInvalid';
const NOT_HEX = 'notHex';
/**
@ -46,6 +44,7 @@ class Zend_Validate_Hex extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be a string",
self::NOT_HEX => "'%value%' has not only hexadecimal digit characters"
);
@ -59,12 +58,14 @@ class Zend_Validate_Hex extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value) && !is_int($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
if (!ctype_xdigit($valueString)) {
$this->_error();
$this->_setValue($value);
if (!ctype_xdigit((string) $value)) {
$this->_error(self::NOT_HEX);
return false;
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hostname.php 14556 2009-03-31 10:35:42Z thomas $
* @version $Id: Hostname.php 17141 2009-07-26 12:49:17Z thomas $
*/
/**
@ -24,11 +24,6 @@
*/
require_once 'Zend/Validate/Abstract.php';
/**
* @see Zend_Loader
*/
require_once 'Zend/Loader.php';
/**
* @see Zend_Validate_Ip
*/
@ -46,11 +41,12 @@ require_once 'Zend/Validate/Ip.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname extends Zend_Validate_Abstract
{
const INVALID = 'hostnameInvalid';
const IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed';
const UNKNOWN_TLD = 'hostnameUnknownTld';
const INVALID_DASH = 'hostnameDashCharacter';
@ -65,6 +61,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be a string",
self::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed",
self::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list",
self::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position",
@ -414,27 +411,34 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue($value);
// Check input against IP address schema
if ($this->_ipValidator->setTranslator($this->getTranslator())->isValid($valueString)) {
if (preg_match('/^[0-9.a-e:.]*$/i', $value) &&
$this->_ipValidator->setTranslator($this->getTranslator())->isValid($value)) {
if (!($this->_allow & self::ALLOW_IP)) {
$this->_error(self::IP_ADDRESS_NOT_ALLOWED);
return false;
} else{
} else {
return true;
}
}
// Check input against DNS hostname schema
$domainParts = explode('.', $valueString);
if ((count($domainParts) > 1) && (strlen($valueString) >= 4) && (strlen($valueString) <= 254)) {
$domainParts = explode('.', $value);
if ((count($domainParts) > 1) && (strlen($value) >= 4) && (strlen($value) <= 254)) {
$status = false;
$origenc = iconv_get_encoding('internal_encoding');
iconv_set_encoding('internal_encoding', 'UTF-8');
do {
// First check TLD
$matches = array();
if (preg_match('/([^.]{2,10})$/i', end($domainParts), $matches) ||
(end($domainParts) == 'ایران') || (end($domainParts) == '中国') ||
(end($domainParts) == '公司') || (end($domainParts) == '网络')) {
@ -496,6 +500,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract
foreach($regexChars as $regexKey => $regexChar) {
$status = @preg_match($regexChar, $domainPart);
if ($status === false) {
iconv_set_encoding('internal_encoding', $origenc);
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('Internal error: DNS validation failed');
} elseif ($status !== 0) {
@ -505,7 +510,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract
$length = $this->_idnLength[strtoupper($this->_tld)];
}
if (iconv_strlen($domainPart) > $length) {
if (iconv_strlen($domainPart, 'UTF-8') > $length) {
$this->_error(self::INVALID_HOSTNAME);
} else {
$check = true;
@ -532,6 +537,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract
}
} while (false);
iconv_set_encoding('internal_encoding', $origenc);
// If the input passes as an Internet domain name, and domain names are allowed, then the hostname
// passes validation
if ($status && ($this->_allow & self::ALLOW_DNS)) {
@ -543,7 +549,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract
// Check input against local network name schema; last chance to pass validation
$regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}){1,254}$/';
$status = @preg_match($regexLocal, $valueString);
$status = @preg_match($regexLocal, $value);
if (false === $status) {
/**
* Regex error
@ -582,9 +588,8 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract
*/
protected function decodePunycode($encoded)
{
$matches = array();
$found = preg_match('/([^a-z0-9\x2d]{1,10})$/i', $encoded);
if (empty($encoded) || (count($matches) > 0)) {
$found = preg_match('/([^a-z0-9\x2d]{1,10})$/i', $encoded);
if (empty($encoded) || ($found > 0)) {
// no punycode encoded string, return as is
$this->_error(self::CANNOT_DECODE_PUNYCODE);
return false;

View File

@ -1,50 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: At.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_At implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see http://www.nic.at/en/service/technical_information/idn/charset_converter/ Austria (.AT)
* @return string
*/
static function getCharacters()
{
return '\x{00EO}-\x{00F6}\x{00F8}-\x{00FF}\x{0153}\x{0161}\x{017E}';
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hostname.php 14417 2009-03-21 22:27:38Z thomas $
* @version $Id: Biz.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -24,7 +24,7 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(

View File

@ -1,50 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ch.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_Ch implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see https://nic.switch.ch/reg/ocView.action?res=EF6GW2JBPVTG67DLNIQXU234MN6SC33JNQQGI7L6#anhang1 Switzerland (.CH)
* @return string
*/
static function getCharacters()
{
return '\x{00EO}-\x{00F6}\x{00F8}-\x{00FF}\x{0153}';
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hostname.php 14417 2009-03-21 22:27:38Z thomas $
* @version $Id: Cn.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -24,7 +24,7 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hostname.php 14417 2009-03-21 22:27:38Z thomas $
* @version $Id: Com.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -24,7 +24,7 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(
@ -32,7 +32,7 @@ return array(
2 => '/^[\x{002d}0-9\x{0370}-\x{03ff}]{1,63}$/iu',
3 => '/^[\x{002d}0-9a-z\x{ac00}-\x{d7a3}]{1,17}$/iu',
4 => '/^[\x{002d}0-9a-z·à-öø-ÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĸĺļľłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž]{1,63}$/iu',
5 => '/^[\x{0021}-\x{007E}\x{3400}-\x{3401}\x{3404}-\x{3406}\x{340C}\x{3416}\x{341C}' .
5 => '/^[\x{002d}0-9A-Za-z\x{3400}-\x{3401}\x{3404}-\x{3406}\x{340C}\x{3416}\x{341C}' .
'\x{3421}\x{3424}\x{3428}-\x{3429}\x{342B}-\x{342E}\x{3430}-\x{3434}\x{3436}' .
'\x{3438}-\x{343C}\x{343E}\x{3441}-\x{3445}\x{3447}\x{3449}-\x{3451}\x{3453}' .
'\x{3457}-\x{345F}\x{3463}-\x{3467}\x{346E}-\x{3471}\x{3473}-\x{3477}\x{3479}-\x{348E}\x{3491}-\x{3497}' .
@ -119,7 +119,7 @@ return array(
'\x{9772}-\x{982B}\x{982D}-\x{98ED}\x{98EF}-\x{99C4}\x{99C6}-\x{9A11}\x{9A14}-\x{9A27}\x{9A29}-\x{9D0D}' .
'\x{9D0F}-\x{9D2B}\x{9D2D}-\x{9D8E}\x{9D90}-\x{9DC5}\x{9DC7}-\x{9E77}\x{9E79}-\x{9EB8}\x{9EBB}-\x{9F20}' .
'\x{9F22}-\x{9F61}\x{9F63}-\x{9FA5}\x{FA28}]{1,20}$/iu',
6 => '/^[\x{0021}-\x{007E}]{1,63}$/iu',
6 => '/^[\x{002d}0-9A-Za-z]{1,63}$/iu',
7 => '/^[\x{00A1}-\x{00FF}]{1,63}$/iu',
8 => '/^[\x{0100}-\x{017f}]{1,63}$/iu',
9 => '/^[\x{0180}-\x{024f}]{1,63}$/iu',
@ -194,4 +194,5 @@ return array(
78 => '/^[\x{FF00}-\x{FFEF}]{1,63}$/iu',
79 => '/^[\x{20000}-\x{2A6DF}]{1,63}$/iu',
80 => '/^[\x{2F800}-\x{2FA1F}]{1,63}$/iu'
);

View File

@ -1,58 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: De.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_De implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see http://www.denic.de/en/domains/idns/liste.html Germany (.DE) alllowed characters
* @return string
*/
static function getCharacters()
{
return '\x{00E1}\x{00E0}\x{0103}\x{00E2}\x{00E5}\x{00E4}\x{00E3}\x{0105}\x{0101}\x{00E6}\x{0107}' .
'\x{0109}\x{010D}\x{010B}\x{00E7}\x{010F}\x{0111}\x{00E9}\x{00E8}\x{0115}\x{00EA}\x{011B}' .
'\x{00EB}\x{0117}\x{0119}\x{0113}\x{011F}\x{011D}\x{0121}\x{0123}\x{0125}\x{0127}\x{00ED}' .
'\x{00EC}\x{012D}\x{00EE}\x{00EF}\x{0129}\x{012F}\x{012B}\x{0131}\x{0135}\x{0137}\x{013A}' .
'\x{013E}\x{013C}\x{0142}\x{0144}\x{0148}\x{00F1}\x{0146}\x{014B}\x{00F3}\x{00F2}\x{014F}' .
'\x{00F4}\x{00F6}\x{0151}\x{00F5}\x{00F8}\x{014D}\x{0153}\x{0138}\x{0155}\x{0159}\x{0157}' .
'\x{015B}\x{015D}\x{0161}\x{015F}\x{0165}\x{0163}\x{0167}\x{00FA}\x{00F9}\x{016D}\x{00FB}' .
'\x{016F}\x{00FC}\x{0171}\x{0169}\x{0173}\x{016B}\x{0175}\x{00FD}\x{0177}\x{00FF}\x{017A}' .
'\x{017E}\x{017C}\x{00F0}\x{00FE}';
}
}

View File

@ -1,50 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Fi.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_Fi implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see http://www.ficora.fi/en/index/palvelut/fiverkkotunnukset/aakkostenkaytto.html Finland (.FI)
* @return string
*/
static function getCharacters()
{
return '\x{00E5}\x{00E4}\x{00F6}';
}
}

View File

@ -1,50 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hu.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_Hu implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see http://www.domain.hu/domain/English/szabalyzat.html Hungary (.HU)
* @return string
*/
static function getCharacters()
{
return '\x{00E1}\x{00E9}\x{00ED}\x{00F3}\x{00F6}\x{0151}\x{00FA}\x{00FC}\x{0171}';
}
}

View File

@ -1,52 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* UTF-8 characters should be written as four character hex codes \x{XXXX}
* For example é (lowercase e with acute) is represented by the hex code \x{00E9}
*
* You only need to include lower-case equivalents of characters since the hostname
* check is case-insensitive
*
* Please document the supported TLDs in the documentation file at:
* manual/en/module_specs/Zend_Validate-Hostname.xml
*
* @see http://en.wikipedia.org/wiki/Internationalized_domain_name
* @see http://www.iana.org/cctld/ Country-Code Top-Level Domains (TLDs)
* @see http://www.columbia.edu/kermit/utf8-t1.html UTF-8 characters
* @return string
*/
static function getCharacters();
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hostname.php 14417 2009-03-21 22:27:38Z thomas $
* @version $Id: Jp.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -24,7 +24,7 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(

View File

@ -1,50 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Li.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_Li implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see https://nic.switch.ch/reg/ocView.action?res=EF6GW2JBPVTG67DLNIQXU234MN6SC33JNQQGI7L6#anhang1 Liechtenstein (.LI)
* @return string
*/
static function getCharacters()
{
return '\x{00EO}-\x{00F6}\x{00F8}-\x{00FF}\x{0153}';
}
}

View File

@ -1,52 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: No.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_No implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see http://www.norid.no/domeneregistrering/idn/idn_nyetegn.en.html Norway (.NO)
* @return string
*/
static function getCharacters()
{
return '\x00E1\x00E0\x00E4\x010D\x00E7\x0111\x00E9\x00E8\x00EA\x\x014B' .
'\x0144\x00F1\x00F3\x00F2\x00F4\x00F6\x0161\x0167\x00FC\x017E\x00E6' .
'\x00F8\x00E5';
}
}

View File

@ -1,50 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Se.php 8064 2008-02-16 10:58:39Z thomas $
*/
/**
* @see Zend_Validate_Hostname_Interface
*/
require_once 'Zend/Validate/Hostname/Interface.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname_Se implements Zend_Validate_Hostname_Interface
{
/**
* Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
*
* @see http://www.iis.se/english/IDN_campaignsite.shtml?lang=en Sweden (.SE)
* @return string
*/
static function getCharacters()
{
return '\x{00E5}\x{00E4}\x{00F6}\x{00FC}\x{00E9}';
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Date.php 13371 2008-12-19 11:41:09Z thomas $
* @version $Id: Iban.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Iban extends Zend_Validate_Abstract

View File

@ -14,49 +14,56 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Identical.php 8118 2008-02-18 16:10:32Z matthew $
* @version $Id: Identical.php 17684 2009-08-20 09:20:36Z yoshida@zend.co.jp $
*/
/** Zend_Validate_Abstract */
/** @see Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Identical extends Zend_Validate_Abstract
{
/**#@+
/**
* Error codes
* @const string
*/
const NOT_SAME = 'notSame';
const MISSING_TOKEN = 'missingToken';
/**#@-*/
/**
* Error messages
* @var array
*/
protected $_messageTemplates = array(
self::NOT_SAME => 'Tokens do not match',
self::NOT_SAME => "The token '%token%' does not match the given token '%value%'",
self::MISSING_TOKEN => 'No token was provided to match against',
);
/**
* @var array
*/
protected $_messageVariables = array(
'token' => '_tokenString'
);
/**
* Original token against which to validate
* @var string
*/
protected $_tokenString;
protected $_token;
/**
* Sets validator options
*
* @param string $token
* @param mixed $token
* @return void
*/
public function __construct($token = null)
@ -68,19 +75,20 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract
/**
* Set token against which to compare
*
* @param string $token
*
* @param mixed $token
* @return Zend_Validate_Identical
*/
public function setToken($token)
{
$this->_token = (string) $token;
$this->_tokenString = (string) $token;
$this->_token = $token;
return $this;
}
/**
* Retrieve token
*
*
* @return string
*/
public function getToken()
@ -91,18 +99,18 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if a token has been set and the provided value
* Returns true if and only if a token has been set and the provided value
* matches that token.
*
* @param string $value
* @param mixed $value
* @return boolean
*/
public function isValid($value)
{
$this->_setValue($value);
$token = $this->getToken();
$this->_setValue((string) $value);
$token = $this->getToken();
if (empty($token)) {
if ($token === null) {
$this->_error(self::MISSING_TOKEN);
return false;
}

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: InArray.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: InArray.php 17470 2009-08-08 22:27:09Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_InArray extends Zend_Validate_Abstract
@ -129,7 +129,7 @@ class Zend_Validate_InArray extends Zend_Validate_Abstract
{
$this->_setValue($value);
if (!in_array($value, $this->_haystack, $this->_strict)) {
$this->_error();
$this->_error(self::NOT_IN_ARRAY);
return false;
}
return true;

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Int.php 13375 2008-12-19 14:16:40Z thomas $
* @version $Id: Int.php 17470 2009-08-08 22:27:09Z thomas $
*/
/**
@ -32,17 +32,19 @@ require_once 'Zend/Locale/Format.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Int extends Zend_Validate_Abstract
{
const INVALID = 'intInvalid';
const NOT_INT = 'notInt';
/**
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be a string or a integer",
self::NOT_INT => "'%value%' does not appear to be an integer"
);
@ -55,7 +57,9 @@ class Zend_Validate_Int extends Zend_Validate_Abstract
*/
public function __construct($locale = null)
{
$this->setLocale($locale);
if ($locale !== null) {
$this->setLocale($locale);
}
}
/**
@ -83,26 +87,38 @@ class Zend_Validate_Int extends Zend_Validate_Abstract
*
* Returns true if and only if $value is a valid integer
*
* @param string $value
* @param string|integer $value
* @return boolean
*/
public function isValid($value)
{
$valueString = (string) $value;
$this->_setValue($valueString);
if (is_bool($value)) {
$this->_error();
if (!is_string($value) && !is_int($value) && !is_float($value)) {
$this->_error(self::INVALID);
return false;
}
try {
if (!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) {
$this->_error();
$this->_setValue($value);
if ($this->_locale === null) {
$locale = localeconv();
$valueFiltered = str_replace($locale['decimal_point'], '.', $value);
$valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered);
if (strval(intval($valueFiltered)) != $valueFiltered) {
$this->_error(self::NOT_INT);
return false;
}
} else {
try {
if (!Zend_Locale_Format::isInteger($value, array('locale' => 'en')) &&
!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) {
$this->_error(self::NOT_INT);
return false;
}
} catch (Zend_Locale_Exception $e) {
$this->_error(self::NOT_INT);
return false;
}
} catch (Zend_Locale_Exception $e) {
$this->_error();
return false;
}
return true;

View File

@ -15,16 +15,16 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Interface.php 16223 2009-06-21 20:04:53Z thomas $
*/
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Validate_Interface

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ip.php 13104 2008-12-08 22:31:50Z tjohns $
* @version $Id: Ip.php 17470 2009-08-08 22:27:09Z thomas $
*/
/**
@ -27,17 +27,19 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Ip extends Zend_Validate_Abstract
{
const INVALID = 'ipInvalid';
const NOT_IP_ADDRESS = 'notIpAddress';
/**
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be a string",
self::NOT_IP_ADDRESS => "'%value%' does not appear to be a valid IP address"
);
@ -51,16 +53,19 @@ class Zend_Validate_Ip extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue($value);
if ((ip2long($valueString) === false) || (long2ip(ip2long($valueString)) !== $valueString)) {
if ((ip2long($value) === false) || (long2ip(ip2long($value)) !== $value)) {
if (!function_exists('inet_pton')) {
$this->_error();
$this->_error(self::NOT_IP_ADDRESS);
return false;
} else if ((@inet_pton($value) === false) ||(inet_ntop(@inet_pton($value)) !== $valueString)) {
$this->_error();
} else if ((@inet_pton($value) === false) ||(inet_ntop(@inet_pton($value)) !== $value)) {
$this->_error(self::NOT_IP_ADDRESS);
return false;
}
}

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: LessThan.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: LessThan.php 17470 2009-08-08 22:27:09Z thomas $
*/
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_LessThan extends Zend_Validate_Abstract
@ -104,7 +104,7 @@ class Zend_Validate_LessThan extends Zend_Validate_Abstract
{
$this->_setValue($value);
if ($this->_max <= $value) {
$this->_error();
$this->_error(self::NOT_LESS);
return false;
}
return true;

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NotEmpty.php 13226 2008-12-14 11:53:29Z thomas $
* @version $Id: NotEmpty.php 17680 2009-08-19 20:02:26Z thomas $
*/
/**
@ -27,18 +27,20 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_NotEmpty extends Zend_Validate_Abstract
{
const INVALID = 'notEmptyInvalid';
const IS_EMPTY = 'isEmpty';
/**
* @var array
*/
protected $_messageTemplates = array(
self::IS_EMPTY => "Value is required and can't be empty"
self::IS_EMPTY => "Value is required and can't be empty",
self::INVALID => "Invalid type given, value should be float, string, array, boolean or integer",
);
/**
@ -51,16 +53,21 @@ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$this->_setValue((string) $value);
if (!is_string($value) && !is_int($value) && !is_float($value) && !is_bool($value) &&
!is_array($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
if (is_string($value)
&& (('' === $value)
|| preg_match('/^\s+$/s', $value))
) {
$this->_error();
$this->_error(self::IS_EMPTY);
return false;
} elseif (!is_string($value) && empty($value)) {
$this->_error();
$this->_error(self::IS_EMPTY);
return false;
}

View File

@ -15,9 +15,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Regex.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Regex.php 17470 2009-08-08 22:27:09Z thomas $
*/
@ -30,18 +30,19 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Regex extends Zend_Validate_Abstract
{
const INVALID = 'regexInvalid';
const NOT_MATCH = 'regexNotMatch';
/**
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be string, integer or float",
self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'"
);
@ -103,20 +104,20 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
if (!is_string($value) && !is_int($value) && !is_float($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($valueString);
$this->_setValue($value);
$status = @preg_match($this->_pattern, $valueString);
$status = @preg_match($this->_pattern, $value);
if (false === $status) {
/**
* @see Zend_Validate_Exception
*/
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$valueString'");
throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$value'");
}
if (!$status) {
$this->_error();
$this->_error(self::NOT_MATCH);
return false;
}
return true;

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Changefreq.php 17470 2009-08-08 22:27:09Z thomas $
*/
/**
@ -32,7 +33,7 @@ require_once 'Zend/Validate/Abstract.php';
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract
@ -79,10 +80,10 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract
}
if (!in_array($value, $this->_changeFreqs, true)) {
$this->_error();
$this->_error(self::NOT_VALID);
return false;
}
return true;
}
}
}

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Lastmod.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -32,7 +33,7 @@ require_once 'Zend/Validate/Abstract.php';
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
@ -77,4 +78,4 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
return @preg_match(self::LASTMOD_REGEX, $value) == 1;
}
}
}

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Loc.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -37,7 +38,7 @@ require_once 'Zend/Uri.php';
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract
@ -75,4 +76,4 @@ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract
return Zend_Uri::check($value);
}
}
}

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Priority.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
@ -32,7 +33,7 @@ require_once 'Zend/Validate/Abstract.php';
* @category Zend
* @package Zend_Validate
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract
@ -71,4 +72,4 @@ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract
$value = (float)$value;
return $value >= 0 && $value <= 1;
}
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: StringLength.php 13277 2008-12-15 19:52:00Z thomas $
* @version $Id: StringLength.php 16223 2009-06-21 20:04:53Z thomas $
*/
/**
@ -27,11 +27,12 @@ require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_StringLength extends Zend_Validate_Abstract
{
const INVALID = 'stringLengthInvalid';
const TOO_SHORT = 'stringLengthTooShort';
const TOO_LONG = 'stringLengthTooLong';
@ -39,6 +40,7 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be a string",
self::TOO_SHORT => "'%value%' is less than %min% characters long",
self::TOO_LONG => "'%value%' is greater than %max% characters long"
);
@ -198,12 +200,16 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract
*/
public function isValid($value)
{
$valueString = (string) $value;
$this->_setValue($valueString);
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
if ($this->_encoding !== null) {
$length = iconv_strlen($valueString, $this->_encoding);
$length = iconv_strlen($value, $this->_encoding);
} else {
$length = iconv_strlen($valueString);
$length = iconv_strlen($value);
}
if ($length < $this->_min) {