_validatorArgs = ''; break; case 2: // parse arguments (no UTF8-treatment necessary) if (substr($typeNameParts[1], -1) != ')') return false; // FIXME: Escape for PHP code inclusion? $this->_validatorArgs = substr($typeNameParts[1], 0, -1); break; } // Validator name must start with a lower case letter // and may contain only alphanumeric letters. if (!PKPString::regexp_match('/^[a-z][a-zA-Z0-9]+$/', $typeNameParts[0])) return false; // Translate the validator name into a validator class name. $this->_validatorClassName = 'Validator'.PKPString::ucfirst($typeNameParts[0]); return true; } /** * @see TypeDescription::checkType() */ function checkType(&$object) { // Check primitive type. if (!parent::checkType($object)) return false; // Instantiate and call validator import('lib.pkp.classes.validation.'.$this->_validatorClassName); assert(class_exists($this->_validatorClassName)); $validatorConstructorCode = 'return new '.$this->_validatorClassName.'('.$this->_validatorArgs.');'; $validator = eval($validatorConstructorCode); assert(is_a($validator, 'Validator')); // Validate the object if (!$validator->isValid($object)) return false; return true; } } ?>