Provides validator abstract with basic error message handling.
More...
List of all members.
Public Member Functions |
| getMessages () |
| Get errors for the most recent isValid() check.
|
| getMessageTemplates () |
| Get the message templates for this validator.
|
Protected Member Functions |
| _error ($messageKey) |
| Record an error detected during validation.
|
| _setValue ($value) |
| Sets the value being validated and clears the messages.
|
Protected Attributes |
| $_messages = array() |
| $_messageTemplates = array() |
| $_value = null |
Detailed Description
Provides validator abstract with basic error message handling.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Member Function Documentation
P4_Validate_Abstract::_error |
( |
$ |
messageKey | ) |
[protected] |
Record an error detected during validation.
Replaces 'value' with the value being validated.
- Parameters:
-
string | $messageKey | the id of the message to add. |
{
if (!array_key_exists($messageKey, $this->_messageTemplates)) {
throw new InvalidArgumentException(
"Cannot set error. Invalid message key given."
);
}
$value = is_object($this->_value)
? get_class($this->_value)
: (string) $this->_value;
$message = $this->_messageTemplates[$messageKey];
$message = str_replace('%value%', (string) $value, $message);
$this->_messages[$messageKey] = $message;
}
P4_Validate_Abstract::_setValue |
( |
$ |
value | ) |
[protected] |
Sets the value being validated and clears the messages.
- Parameters:
-
mixed | $value | the value being validated. |
{
$this->_value = $value;
$this->_messages = array();
}
P4_Validate_Abstract::getMessages |
( |
| ) |
|
Get errors for the most recent isValid() check.
- Returns:
- array list of error messages.
{
return $this->_messages;
}
P4_Validate_Abstract::getMessageTemplates |
( |
| ) |
|
Get the message templates for this validator.
- Returns:
- array list of error message templates.
{
return $this->_messageTemplates;
}
Member Data Documentation
P4_Validate_Abstract::$_messages = array() [protected] |
P4_Validate_Abstract::$_messageTemplates = array() [protected] |
P4_Validate_Abstract::$_value = null [protected] |
The documentation for this class was generated from the following file: