Perforce Chronicle 2012.2/486814
API Documentation
|
Validates input for suitability as a Perforce change number. More...
Public Member Functions | |
isValid ($value) | |
Checks if the given string is a valid change number. | |
Public Attributes | |
const | INVALID_NUMBER = 'invalidNumber' |
const | INVALID_TYPE = 'invalidType' |
Protected Attributes | |
$_messageTemplates |
Validates input for suitability as a Perforce change number.
Permits the literal string 'default' and integers or strings (that are all digits) with an integer value > 0.
P4_Validate_ChangeNumber::isValid | ( | $ | value | ) |
Checks if the given string is a valid change number.
string | int | $value | change number to validate. |
{ $this->_setValue($value); // 'default' change is a special case that we allow. if ($value === P4_Change::DEFAULT_CHANGE) { return true; } // test for valid type. if (!is_int($value) && !is_string($value)) { $this->_error(self::INVALID_TYPE); return false; } // test for a string with anything other than digits. if (is_string($value) && preg_match('/[^0-9]/', $value)) { $this->_error(self::INVALID_TYPE); return false; } // test for value less than one. if (intval($value) < 1) { $this->_error(self::INVALID_NUMBER); return false; } return true; }
P4_Validate_ChangeNumber::$_messageTemplates [protected] |
array( self::INVALID_TYPE => 'Change number must be an integer or purely numeric string.', self::INVALID_NUMBER => 'Change numbers must be greater than zero.' )
Reimplemented from P4_Validate_Abstract.
const P4_Validate_ChangeNumber::INVALID_NUMBER = 'invalidNumber' |
const P4_Validate_ChangeNumber::INVALID_TYPE = 'invalidType' |