Skip to content

Commit

Permalink
merge: Implement some feedback about model validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Sep 23, 2024
2 parents 476cc4a + 4aa30f4 commit 90a13d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions capellambse/extensions/validation/_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ def rule(
action: str,
types: (
str
| VirtualType[_T]
| type[_T]
| cabc.Iterable[str | VirtualType[_T] | type[_T]]
| VirtualType[m.ModelElement]
| type[m.ModelElement]
| cabc.Iterable[str | VirtualType[m.ModelElement] | type[m.ModelElement]]
),
) -> cabc.Callable[[cabc.Callable[[_T], bool]], Rule]:
) -> cabc.Callable[[cabc.Callable[[m.ModelElement], bool]], Rule]:
"""Create a validation rule.
This decorator registers the validator function as a modelling rule.
Expand Down Expand Up @@ -376,7 +376,7 @@ def rule(
else:
type_names.append(i.__name__)

def rule_decorator(validator: cabc.Callable[[_T], bool], /) -> Rule:
def rule_decorator(validator: cabc.Callable[[m.ModelElement], bool], /) -> Rule:
rule_ = Rule(
id,
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% set CATEGORIES = ["REQUIRED", "RECOMMENDED", "SUGGESTED"] -%}
{% set object_types = [
"Capability",
"SystemCapability",
"SystemActor",
"SystemComponent",
"SystemFunction",
Expand Down
5 changes: 5 additions & 0 deletions capellambse/extensions/validation/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
from ._validate import rule, virtual_type


@virtual_type(mm.sa.Capability)
def SystemCapability(_: mm.sa.Capability) -> bool:
return True


@virtual_type(mm.sa.SystemComponent)
def SystemActor(cmp: mm.sa.SystemComponent) -> bool:
return cmp.is_actor
Expand Down

0 comments on commit 90a13d4

Please sign in to comment.