## API Documentation

# Validate/Abstract.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
copyright
  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
license
  New BSD License
package
  Zend_Validate
version
  $Id: Abstract.php 23775 2011-03-01 17:25:24Z ralph $

## \Zend_Validate_Abstract
jump to top

Implements
  \Zend_Validate_Interface
category
  Zend
copyright
  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
license
  New BSD License
package
  Zend_Validate

### Properties

`\Zend_Translate $_defaultTranslator= ''`
static

Default translation object for all validate objects

Details

Type
  \Zend_Translate

`array $_errors= 'array'`

Array of validation failure message codes

Default value `array` Details

Type
  array
deprecated
  Since 1.5.0

`Integer $_messageLength= ''`
static

Limits the maximum returned length of a error message

Details

Type
  Integer

`array $_messageTemplates= 'array'`

Validation failure message template definitions

Default value `array` Details

Type
  array

`array $_messageVariables= 'array'`

Additional variables available for validation failure messages

Default value `array` Details

Type
  array

`array $_messages= 'array'`

Array of validation failure messages

Default value `array` Details

Type
  array

`bool $_obscureValue= 'false'`

Flag indidcating whether or not value should be obfuscated in error messages

Default value `false` Details

Type
  bool

`\Zend_Translate $_translator= ''`

Translation object

Details

Type
  \Zend_Translate

`Boolean $_translatorDisabled= 'false'`

Is translation disabled?

Default value `false` Details

Type
  Boolean

`mixed $_value= ''`

The value to be validated

Details

Type
  mixed

### Methods

`__get( string $property ) : mixed`

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

Parameters

Name | Type | Description
--- | --- | ---
$property | string |

Returns

Type | Description
--- | ---
mixed |

Throws

Exception | Description
--- | ---
\Zend_Validate_Exception |

`_createMessage( string $messageKey, string $value ) : string`

Constructs and returns a validation failure message with the given message key and value.

Returns null if and only if $messageKey does not correspond to an existing template.

If a translator is available and a translation exists for $messageKey, the translation will be used.

Parameters

Name | Type | Description
--- | --- | ---
$messageKey | string |
$value | string |

Returns

Type | Description
--- | ---
string |

`_error( string $messageKey, string $value = null ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$messageKey | string |
$value | string | OPTIONAL

`_setValue( mixed $value ) : void`

Sets the value to be validated and clears the messages and errors arrays

Parameters

Name | Type | Description
--- | --- | ---
$value | mixed |

`getDefaultTranslator( ) : \Zend_Translate_Adapter|null`
static

Get default translation object for all validate objects

Returns

Type | Description
--- | ---
\Zend_Translate_Adapternull |

`getErrors( ) : array`

Returns array of validation failure message codes

Returns

Type | Description
--- | ---
array |

Details

deprecated
  Since 1.5.0

`getMessageLength( ) : integer`
static

Returns the maximum allowed message length

Returns

Type | Description
--- | ---
integer |

`getMessageTemplates( ) : array`

Returns the message templates from the validator

Returns

Type | Description
--- | ---
array |

`getMessageVariables( ) : array`

Returns an array of the names of variables that are used in constructing validation failure messages

Returns

Type | Description
--- | ---
array |

`getMessages( ) : array`

Returns array of validation failure messages

If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.

Returns

Type | Description
--- | ---
array |

`getObscureValue( ) : bool`

Retrieve flag indicating whether or not value should be obfuscated in messages

Returns

Type | Description
--- | ---
bool |

`getTranslator( ) : \Zend_Translate_Adapter|null`

Return translation object

Returns

Type | Description
--- | ---
\Zend_Translate_Adapternull |

`hasDefaultTranslator( ) : boolean`
static

Is there a default translation object set?

Returns

Type | Description
--- | ---
boolean |

`hasTranslator( ) : bool`

Does this validator have its own specific translator?

Returns

Type | Description
--- | ---
bool |

`isValid( mixed $value ) : boolean`

Returns true if and only if $value meets the validation requirements

Inherited from: \Zend_Validate_Interface::isValid()

If $value fails validation, then this method returns false, and getMessages() will return an array of messages that explain why the validation failed.

Parameters

Name | Type | Description
--- | --- | ---
$value | mixed |

Returns

Type | Description
--- | ---
boolean |

Throws

Exception | Description
--- | ---
\Zend_Validate_Exception | If validation of $value is impossible

`setDefaultTranslator( \Zend_Translate|\Zend_Translate_Adapter|null $translator = null ) : void`
static

Set default translation object for all validate objects

Parameters

Name | Type | Description
--- | --- | ---
$translator | \Zend_Translate|\Zend_Translate_Adapter|null |

`setDisableTranslator( bool $flag ) : \Zend_Validate_Abstract`

Indicate whether or not translation should be disabled

Parameters

Name | Type | Description
--- | --- | ---
$flag | bool |

Returns

Type | Description
--- | ---
\Zend_Validate_Abstract |

`setMessage( string $messageString, string $messageKey = null ) : \Zend_Validate_Abstract`

Sets the validation failure message template for a particular key

Parameters

Name | Type | Description
--- | --- | ---
$messageString | string |
$messageKey | string | OPTIONAL

Returns

Type | Description
--- | ---
\Zend_Validate_Abstract | Provides a fluent interface

Throws

Exception | Description
--- | ---
\Zend_Validate_Exception |

`setMessageLength( integer $length ) : void`
static

Sets the maximum allowed message length

Parameters

Name | Type | Description
--- | --- | ---
$length | integer |

`setMessages( array $messages ) : \Zend_Validate_Abstract`

Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.

Parameters

Name | Type | Description
--- | --- | ---
$messages | array |

Returns

Type | Description
--- | ---
\Zend_Validate_Abstract |

`setObscureValue( bool $flag ) : \Zend_Validate_Abstract`

Set flag indicating whether or not value should be obfuscated in messages

Parameters

Name | Type | Description
--- | --- | ---
$flag | bool |

Returns

Type | Description
--- | ---
\Zend_Validate_Abstract |

`setTranslator( \Zend_Translate|\Zend_Translate_Adapter|null $translator = null ) : \Zend_Validate_Abstract`

Set translation object

Parameters

Name | Type | Description
--- | --- | ---
$translator | \Zend_Translate|\Zend_Translate_Adapter|null |

Returns

Type | Description
--- | ---
\Zend_Validate_Abstract |

`translatorIsDisabled( ) : bool`

Is translation disabled?

Returns

Type | Description
--- | ---
bool |

Documentation was generated by DocBlox 0.13.3.