/ */ class P4Cms_Validate_RecordField extends P4_Validate_AttributeName { const LEADING_UNDERSCORE = 'leadingUnderscore'; /** * Add a message template upon instantiation. */ public function __construct() { $message = "First character cannot be underscore ('_')."; $this->_messageTemplates[self::LEADING_UNDERSCORE] = $message; } /** * Checks if the given string is a valid record field name. * * @param string $value the value to validate. * @return boolean true if value is a valid field name, false otherwise. */ public function isValid($value) { // test for leading underscore ('_') character. if ($value[0] === "_") { $this->_error(static::LEADING_UNDERSCORE); return false; } return parent::isValid($value); } }