Perforce Chronicle 2012.2/486814
API Documentation

P4_Validate_Abstract Class Reference

Provides validator abstract with basic error message handling. More...

Inheritance diagram for P4_Validate_Abstract:
P4_Validate_ChangeNumber P4_Validate_KeyName P4_Validate_Port P4_Validate_StrongPassword P4_Validate_AttributeName P4_Validate_CounterName P4_Validate_GroupName P4_Validate_SpecName P4_Validate_StreamName P4_Validate_UserName P4Cms_Validate_RecordField P4Cms_Validate_ContentTypeElementName

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$messageKeythe id of the message to add.
    {
        if (!array_key_exists($messageKey, $this->_messageTemplates)) {
            throw new InvalidArgumentException(
                "Cannot set error. Invalid message key given."
            );
        }

        // support %value% substitution.
        $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$valuethe 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: