Skip to content

Commit fd5fa44

Browse files
committed
(i) Removed minimum length requirement for name; (ii) split rule for actionStatus into two: a SHOULD (for existance) and a MUST (for proper values)
1 parent 994b586 commit fd5fa44

File tree

4 files changed

+71
-57
lines changed

4 files changed

+71
-57
lines changed

rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ five-safes-crate:ValidationCheckObjectHasDescriptiveNameAndIsAssessAction
5252
sh:property [
5353
sh:a sh:PropertyShape ;
5454
sh:name "name" ;
55-
sh:description "ValidationCheck MUST have a human readable name string of at least 10 characters." ;
55+
sh:description "ValidationCheck MUST have a human readable name string." ;
5656
sh:path schema:name ;
5757
sh:datatype xsd:string ;
58-
sh:minLength 10 ;
5958
sh:severity sh:Violation ;
60-
sh:message "ValidationCheck MUST have a human readable name string of at least 10 characters." ;
59+
sh:message "ValidationCheck MUST have a human readable name string." ;
6160
] .
6261

6362

@@ -91,4 +90,37 @@ five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue
9190
) ;
9291
sh:severity sh:Violation ;
9392
sh:message "The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)." ;
94-
] .
93+
] .
94+
95+
96+
five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue
97+
a sh:NodeShape ;
98+
sh:name "ValidationCheck" ;
99+
sh:target [
100+
a sh:SPARQLTarget ;
101+
sh:select """
102+
PREFIX schema: <http://schema.org/>
103+
PREFIX shp: <https://w3id.org/shp#>
104+
105+
SELECT ?this
106+
WHERE {
107+
?this schema:additionalType shp:ValidationCheck .
108+
}
109+
""" ;
110+
] ;
111+
112+
sh:property [
113+
a sh:PropertyShape ;
114+
sh:minCount 1 ;
115+
sh:name "actionStatus" ;
116+
sh:description "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ;
117+
sh:path schema:actionStatus ;
118+
sh:in (
119+
"http://schema.org/PotentialActionStatus"
120+
"http://schema.org/ActiveActionStatus"
121+
"http://schema.org/CompletedActionStatus"
122+
"http://schema.org/FailedActionStatus"
123+
) ;
124+
sh:severity sh:Violation ;
125+
sh:message "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ;
126+
] .

rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ five-safes-crate:ValidationCheckObjectShouldPointToRootDataEntity
6565
""" ;
6666
] ;
6767

68-
sh:property [
69-
a sh:PropertyShape ;
68+
sh:sparql [
69+
a sh:SPARQLConstraint ;
7070
sh:name "object" ;
71-
sh:path schema:object ;
72-
sh:minCount 1 ;
73-
sh:hasValue <./> ;
71+
sh:select """
72+
PREFIX schema: <http://schema.org/>
73+
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>
74+
SELECT $this
75+
WHERE {
76+
FILTER NOT EXISTS {
77+
$this schema:object rocrate:RootDataEntity .
78+
}
79+
}
80+
""" ;
7481
sh:severity sh:Warning ;
7582
sh:message "`ValidationCheck` --> `object` SHOULD point to the root of the RO-Crate" ;
7683
] .
@@ -131,37 +138,3 @@ five-safes-crate:ValidationCheckShouldHaveActionStatus
131138
sh:severity sh:Warning ;
132139
sh:message "ValidationCheck SHOULD have actionStatus property." ;
133140
] .
134-
135-
136-
137-
five-safes-crate:ValidationCheckShouldHaveActionStatus
138-
a sh:NodeShape ;
139-
sh:name "ValidationCheck" ;
140-
sh:target [
141-
a sh:SPARQLTarget ;
142-
sh:select """
143-
PREFIX schema: <http://schema.org/>
144-
PREFIX shp: <https://w3id.org/shp#>
145-
146-
SELECT ?this
147-
WHERE {
148-
?this schema:additionalType shp:ValidationCheck .
149-
}
150-
""" ;
151-
] ;
152-
153-
sh:property [
154-
a sh:PropertyShape ;
155-
sh:minCount 1 ;
156-
sh:name "actionStatus" ;
157-
sh:description "ValidationCheck SHOULD have the `actionStatus` property." ;
158-
sh:path schema:actionStatus ;
159-
sh:in (
160-
"http://schema.org/PotentialActionStatus"
161-
"http://schema.org/ActiveActionStatus"
162-
"http://schema.org/CompletedActionStatus"
163-
"http://schema.org/FailedActionStatus"
164-
) ;
165-
sh:severity sh:Warning ;
166-
sh:message "ValidationCheck SHOULD have the `actionStatus` property." ;
167-
] .

tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ def test_5src_validation_check_name_not_a_string():
7070
requirement_severity=Severity.REQUIRED,
7171
expected_validation_result=False,
7272
expected_triggered_requirements=["ValidationCheck"],
73-
expected_triggered_issues=["ValidationCheck MUST have a human readable name string of at least 10 characters."],
73+
expected_triggered_issues=["ValidationCheck MUST have a human readable name string."],
7474
profile_identifier="five-safes-crate",
7575
rocrate_entity_mod_sparql=sparql,
7676
)
7777

7878

79-
def test_5src_validation_check_name_not_long_enough():
79+
def test_5src_validation_check_has_action_status_with_not_allowed_value():
8080
sparql = (SPARQL_PREFIXES + """
8181
DELETE {
82-
?this schema:name ?name .
82+
?s schema:actionStatus ?o .
8383
}
8484
INSERT {
85-
?this schema:name "Short" .
85+
?s schema:actionStatus "Not a good action status" .
8686
}
8787
WHERE {
88-
?this schema:additionalType shp:ValidationCheck .
88+
?s schema:additionalType <https://w3id.org/shp#ValidationCheck> .
8989
}
9090
""")
9191

@@ -94,34 +94,42 @@ def test_5src_validation_check_name_not_long_enough():
9494
requirement_severity=Severity.REQUIRED,
9595
expected_validation_result=False,
9696
expected_triggered_requirements=["ValidationCheck"],
97-
expected_triggered_issues=["ValidationCheck MUST have a human readable name string of at least 10 characters."],
97+
expected_triggered_issues=[(
98+
"The `actionStatus` of ValidationCheck MUST have an allowed value "
99+
"(see https://schema.org/ActionStatusType)."
100+
)],
98101
profile_identifier="five-safes-crate",
99102
rocrate_entity_mod_sparql=sparql,
100103
)
101104

102-
103105
def test_5src_validation_check_has_action_status_with_not_allowed_value():
104-
sparql = (SPARQL_PREFIXES + """
106+
sparql = (
107+
SPARQL_PREFIXES
108+
+ """
105109
DELETE {
106110
?s schema:actionStatus ?o .
107111
}
108112
INSERT {
109113
?s schema:actionStatus "Not a good action status" .
110114
}
111115
WHERE {
112-
?s schema:additionalType <https://w3id.org/shp#ValidationCheck> .
116+
?s schema:additionalType shp:ValidationCheck ;
117+
schema:actionStatus ?o .
113118
}
114-
""")
119+
"""
120+
)
115121

116122
do_entity_test(
117123
rocrate_path=ValidROC().five_safes_crate_result,
118124
requirement_severity=Severity.REQUIRED,
119125
expected_validation_result=False,
120126
expected_triggered_requirements=["ValidationCheck"],
121-
expected_triggered_issues=[(
122-
"The `actionStatus` of ValidationCheck MUST have an allowed value "
123-
"(see https://schema.org/ActionStatusType)."
124-
)],
127+
expected_triggered_issues=[
128+
(
129+
"The value of actionStatus MUST be one of the allowed values: "
130+
"PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus."
131+
)
132+
],
125133
profile_identifier="five-safes-crate",
126134
rocrate_entity_mod_sparql=sparql,
127135
)

tests/shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
PREFIX schema: <http://schema.org/>
3939
PREFIX shp: <https://w3id.org/shp#>
4040
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
41+
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>
4142
"""
4243

4344

0 commit comments

Comments
 (0)