Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Validate_SiteId Class Reference

Validates string for suitability as a site id. More...

List of all members.

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

Detailed Description

Validates string for suitability as a site id.

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

P4Cms_Validate_SiteId::isValid ( value)

Checks if the given string appears to be in a valid site id format.

Parameters:
string$valuethe site id value to validate.
Returns:
boolean true if value is valid, false otherwise.
    {
        // 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;
    }

Member Data Documentation

P4Cms_Validate_SiteId::$_messageTemplates [protected]
Initial value:
 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'

The documentation for this class was generated from the following file: