def validate(self): """ Checks if the attributes of the class are valid :returns: Boolean """ # TODO: Verify validation of AttributeDefinition Object ObjectValidator.validateAlNum(self, 'name', withSpaces=True, withSymbols=True, minLength=3) ObjectValidator.validateAlNum(self, 'description', withNonPrintableCharacters=True, withSpaces=True, minLength=3, withSymbols=True) ObjectValidator.validateRegularExpression(self, 'regex') # check if handler is compatible with the class_index allowed_tables = self.handler.get_allowed_types() if not (self.table_id in allowed_tables): self.class_index = FailedValidation( self.table_id, ('Class is not compatible "{0}".\n' 'Supported classes are {1}').format( self.attribute_handler.classname, self.__class_numbers_to_text(allowed_tables))) return ObjectValidator.isObjectValid(self)
def validateRegularExpression(regex): """ Validates if the attribute is a valid regular expression. Note: The actual object is changed internally :param regex: regular expression to be validated :type regex: String :return Boolean """ obj = Container(regex) return ObjectValidator.validateRegularExpression(obj, 'value', changeAttribute=False)