|
Perforce Chronicle 2012.2/486814
API Documentation
|
Validates string for suitability as a site id. More...
Public Member Functions | |
| isValid ($value) | |
| Checks if the given string appears to be in a valid site id format. | |
Public Attributes | |
| const | INVALID_CHARACTERS = 'invalidCharacters' |
| const | MISSING_PREFIX = 'missingPrefix' |
Protected Attributes | |
| $_messageTemplates | |
Validates string for suitability as a site id.
| P4Cms_Validate_SiteId::isValid | ( | $ | value | ) |
Checks if the given string appears to be in a valid site id format.
| string | $value | the site id value to validate. |
{
// check for invalid characters.
if (preg_match('/[^a-z0-9\-]/i', $value)) {
$this->_error(self::INVALID_CHARACTERS);
return false;
}
// check for site id prefix.
if (strpos($value, P4Cms_Site::SITE_PREFIX) !== 0) {
$this->_error(self::MISSING_PREFIX);
return false;
}
return true;
}
P4Cms_Validate_SiteId::$_messageTemplates [protected] |
array(
self::INVALID_CHARACTERS
=> "A site id may only contain alphanumeric characters and dash ('-').",
self::MISSING_PREFIX
=> "The given site id is missing the expected prefix."
)
| const P4Cms_Validate_SiteId::INVALID_CHARACTERS = 'invalidCharacters' |
| const P4Cms_Validate_SiteId::MISSING_PREFIX = 'missingPrefix' |