Definition at line 33 of file StringLength.php.
◆ __construct()
__construct |
( |
|
$options = array() | ) |
|
Sets validator options
- Parameters
-
Definition at line 84 of file StringLength.php.
90 $temp[
'min'] = array_shift(
$options);
92 $temp[
'max'] = array_shift(
$options);
96 $temp[
'encoding'] = array_shift(
$options);
102 if (!array_key_exists(
'min',
$options)) {
107 if (array_key_exists(
'max',
$options)) {
111 if (array_key_exists(
'encoding',
$options)) {
setEncoding($encoding=null)
◆ getEncoding()
◆ getMax()
◆ getMin()
◆ isValid()
Defined by Zend_Validate_Interface
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).
- Parameters
-
- Returns
- boolean
Implements Zend_Validate_Interface.
Definition at line 239 of file StringLength.php.
242 $this->
_error(self::INVALID);
247 if ($this->_encoding !==
null) {
248 $length = iconv_strlen(
$value, $this->_encoding);
250 $length = iconv_strlen(
$value);
253 if ($length < $this->_min) {
254 $this->
_error(self::TOO_SHORT);
257 if (
null !== $this->_max && $this->_max < $length) {
258 $this->
_error(self::TOO_LONG);
261 if (count($this->_messages)) {
_error($messageKey, $value=null)
◆ setEncoding()
setEncoding |
( |
|
$encoding = null | ) |
|
Sets a new encoding to use
- Parameters
-
- Exceptions
-
- Returns
- Zend_Validate_StringLength
Definition at line 199 of file StringLength.php.
201 if ($encoding !==
null) {
202 $orig = PHP_VERSION_ID < 50600
203 ? iconv_get_encoding(
'internal_encoding')
205 if (PHP_VERSION_ID < 50600) {
207 $result = iconv_set_encoding(
'internal_encoding', $encoding);
212 ini_set(
'default_charset', $encoding);
216 #require_once 'Zend/Validate/Exception.php'; 220 if (PHP_VERSION_ID < 50600) {
221 iconv_set_encoding(
'internal_encoding', $orig);
223 ini_set(
'default_charset', $orig);
226 $this->_encoding = $encoding;
ini_set($varName, $newValue)
◆ setMax()
◆ setMin()
◆ $_encoding
◆ $_max
◆ $_messageTemplates
Initial value:= array(
self::INVALID => "Invalid type given. String expected",
self::TOO_SHORT => "'%value%' is less than %min% characters long",
self::TOO_LONG => "'%value%' is more than %max% characters long",
)
Definition at line 42 of file StringLength.php.
◆ $_messageVariables
Initial value:= array(
'min' => '_min',
'max' => '_max'
)
Definition at line 51 of file StringLength.php.
◆ $_min
◆ INVALID
const INVALID = 'stringLengthInvalid' |
◆ TOO_LONG
const TOO_LONG = 'stringLengthTooLong' |
◆ TOO_SHORT
const TOO_SHORT = 'stringLengthTooShort' |
The documentation for this class was generated from the following file: