Пример #1
0
 def _validate_one(self, resource: Resource) -> None:
     # If the resource is not typed, AttributeError is raised: run() sets _validated to False.
     type_ = resource.type
     type_expanded = self.service.expand(type_)
     schema = self.service.schema(type_expanded)
     result, reason = self.service.check(resource, schema)
     if reason is not None:
         raise ValidationError(reason)
Пример #2
0
 def _validate_many(self, resources: List[Resource]) -> None:
     for resource in resources:
         conforms, graph, _ = self.service.validate(resource)
         if conforms:
             resource._validated = True
             action = Action(self._validate_many.__name__, conforms, None)
         else:
             resource._validated = False
             violations = set(" ".join(re.findall('[A-Z][^A-Z]*', as_term(o)))
                              for o in graph.objects(None, SH.sourceConstraintComponent))
             message = f"violation(s) of type(s) {', '.join(sorted(violations))}"
             action = Action(self._validate_many.__name__, conforms, ValidationError(message))
         resource._last_action = action
Пример #3
0
 def _validate_one(self, resource: Resource) -> None:
     conforms, _, report = self.service.validate(resource)
     if conforms is False:
         raise ValidationError("\n" + report)