def validate(self, value): self.value_msg = value if self.property_type in scalarunit.ScalarUnit.SCALAR_UNIT_TYPES: value = scalarunit.get_scalarunit_value(self.property_type, value) if not self._is_valid(value): err_msg = self._err_msg(value) raise ValidationError(message=err_msg)
def evaluate(self, attributes): if self.name == 'not': for condition in self.conditions: if not condition.evaluate(attributes): return True return False elif self.name in ['and', 'assert']: for condition in self.conditions: if not condition.evaluate(attributes): return False return True elif self.name == 'or': for condition in self.conditions: if condition.evaluate(attributes): return True else: # 3.6.25.3 Direct assertion definition if self.name not in attributes: return False value = attributes[self.name] for condition in self.conditions: if condition.property_type in scalarunit.ScalarUnit.SCALAR_UNIT_TYPES: value = scalarunit.get_scalarunit_value( condition.property_type, value) if not condition._is_valid(value): return False log.warning("value matched %s on %s", value, self.name) return True
def validate(self, value): self.value_msg = value if self.property_type in scalarunit.ScalarUnit.SCALAR_UNIT_TYPES: value = scalarunit.get_scalarunit_value(self.property_type, value) if not self._is_valid(value): err_msg = self._err_msg(value) ExceptionCollector.appendException(ValidationError(message=err_msg))