Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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))