Perforce Chronicle 2012.2/486814
API Documentation

P4_Validate_StreamName Class Reference

Validates string for suitability as a Perforce stream name. More...

Inheritance diagram for P4_Validate_StreamName:
P4_Validate_KeyName P4_Validate_Abstract

List of all members.

Public Member Functions

 __construct ()
 Revised message templates upon instantiation.
 isValid ($value)
 Checks if the given string is a valid perforce spec name.

Public Attributes

const INVALID_FORMAT = 'format'

Protected Attributes

 $_allowCommas = false
 $_allowPercent = false
 $_allowPositional = true
 $_allowRelative = false
 $_allowSlashes = true

Detailed Description

Validates string for suitability as a Perforce stream name.

Extends spec-name to verify we lead with two slashes and contain a third. Also toggles some default settings to match p4ds validation.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Constructor & Destructor Documentation

P4_Validate_StreamName::__construct ( )

Revised message templates upon instantiation.

    {
        $message = "Value is not the correct format of '//depotname/string'";
        $this->_messageTemplates[self::INVALID_FORMAT] = $message;
    }

Member Function Documentation

P4_Validate_StreamName::isValid ( value)

Checks if the given string is a valid perforce spec name.

Parameters:
string | int$valuespec name value to validate.
Returns:
boolean true if value is a valid spec name, false otherwise.

Reimplemented from P4_Validate_KeyName.

    {
        if (!parent::isValid($value)) {
            return false;
        }

        // verify stream is in the format //depotname/string
        if (!preg_match('#^//[^/]+/[^/]+$#', $value)) {
            $this->_error(static::INVALID_FORMAT);
            return false;
        }

        return true;
    }

Member Data Documentation

P4_Validate_StreamName::$_allowCommas = false [protected]

Reimplemented from P4_Validate_KeyName.

P4_Validate_StreamName::$_allowPercent = false [protected]

Reimplemented from P4_Validate_KeyName.

P4_Validate_StreamName::$_allowPositional = true [protected]

Reimplemented from P4_Validate_KeyName.

P4_Validate_StreamName::$_allowRelative = false [protected]

Reimplemented from P4_Validate_KeyName.

P4_Validate_StreamName::$_allowSlashes = true [protected]

Reimplemented from P4_Validate_KeyName.


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