|
Perforce Chronicle 2012.2/486814
API Documentation
|
Validates string for suitability as a category id. More...
Public Member Functions | |
| __construct () | |
| Revise message templates upon instantiation. | |
| isValid ($value) | |
| Defined by Zend_Validate_Interface. | |
Public Attributes | |
| const | INVALID_TYPE = 'invalidType' |
| const | IS_EMPTY = 'isEmpty' |
| const | LEADING_DASH = 'leadingDash' |
| const | LEADING_PERIOD = 'leadingPeriod' |
| const | LEADING_SLASH = 'leadingSlash' |
| const | RESERVED_ID = 'reservedId' |
Validates string for suitability as a category id.
Disallows backslash ('\'), revision characters ('#', '@'), wildcards ('*', '...', '%n'), and others ('_', '', '.')
| P4Cms_Validate_CategoryId::__construct | ( | ) |
Revise message templates upon instantiation.
{
$message = "Only '-', '.' and alpha-numeric characters are permitted in category ids.";
$this->_messageTemplates[self::ILLEGAL_CHARACTERS] = $message;
$this->_messageTemplates[self::LEADING_PERIOD] = 'Leading periods are not permitted in category ids.';
$this->_messageTemplates[self::LEADING_DASH] = 'Leading dashes are not permitted in category ids.';
$this->_messageTemplates[self::LEADING_SLASH] = 'Leading slashes are not permitted in category ids.';
$this->_messageTemplates[self::RESERVED_ID] = 'Id is reserved for internal use.';
$this->_messageTemplates[self::INVALID_TYPE] = 'Invalid type given.';
$this->_messageTemplates[self::IS_EMPTY] = 'Is an empty string.';
}
| P4Cms_Validate_CategoryId::isValid | ( | $ | value | ) |
Defined by Zend_Validate_Interface.
Checks if the given string is a valid site name.
| string | $value | The value to validate. |
Reimplemented from P4Cms_Validate_RecordId.
{
$this->_setValue($value);
// test for valid type.
if (!is_string($value)) {
$this->_error(static::INVALID_TYPE);
return false;
}
// test for empty value.
if ($value === '') {
$this->_error(static::IS_EMPTY);
return false;
}
// test for conflict with metadata file.
if ($value == P4Cms_Categorization_CategoryAbstract::CATEGORY_FILENAME) {
$this->_error(self::RESERVED_ID);
return false;
}
// test for leading . or - which would break sorted output.
if (isset($value[0])) {
if (preg_match(':^\.+|/\.+:', $value)) {
$this->_error(self::LEADING_PERIOD);
return false;
}
if ($value[0] === '-') {
$this->_error(self::LEADING_DASH);
return false;
}
if ($value[0] === '/') {
$this->_error(self::LEADING_SLASH);
return false;
}
}
return parent::isValid($value);
}
| const P4Cms_Validate_CategoryId::INVALID_TYPE = 'invalidType' |
Reimplemented from P4Cms_Validate_RecordId.
| const P4Cms_Validate_CategoryId::IS_EMPTY = 'isEmpty' |
| const P4Cms_Validate_CategoryId::LEADING_DASH = 'leadingDash' |
| const P4Cms_Validate_CategoryId::LEADING_PERIOD = 'leadingPeriod' |
| const P4Cms_Validate_CategoryId::LEADING_SLASH = 'leadingSlash' |
| const P4Cms_Validate_CategoryId::RESERVED_ID = 'reservedId' |