def Validate(self): """Check the method is well constructed.""" if not self.check_id: raise checks.DefinitionError("Check has missing check_id value") cls_name = self.check_id if not self.method: raise checks.DefinitionError("Check %s has no methods" % cls_name) ValidateMultiple(self.method, "Check %s has invalid method definitions" % cls_name)
def Validate(self): """The filter exists, and has valid filter and hint expressions.""" if self.type not in filters.Filter.classes: raise checks.DefinitionError("Undefined filter type %s" % self.type) self._filter.Validate(self.expression) ValidateMultiple(self.hint, "Filter has invalid hint")
def ValidateMultiple(component, hint): errors = [] for item in component: try: item.Validate() except (checks.DefinitionError) as e: errors.append(str(e)) if errors: raise checks.DefinitionError("%s:\n %s" % (hint, "\n ".join(errors)))