Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ Adds validation of policies that use [ODRL profiles](https://www.w3.org/TR/odrl-
- **Input without a policy**: input that contains no typed ODRL policy now returns `valid: false` with "No valid policy provided".
- **Normalisation errors**: a failing normalisation step returns a result with the error instead of throwing.

### Known limitations
- **Profiles are not scoped per policy**: all loaded profiles are merged into one shape. Terms from one loaded profile are therefore accepted in a policy that declares only another profile, or no profile at all.
- **Profile policy types leak between instances**: the constructor modifies the shared `POLICY_TYPES` list, so profile policy types also count as policy types in validators created later.
- **Policy subclasses**: only profile subclasses of `odrl:Policy` itself are recognised as policy types, not subclasses of `odrl:Set`, `odrl:Offer`, etc.
- **New rule types**: a profile subclass of `odrl:Rule` has no property that links it to a policy, and profiles do not define one yet.

## 0.1.0 (2026-06-29)

Expand Down
4 changes: 3 additions & 1 deletion src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface ValidationResult {
focusNode?: string;
valueNode?: string;
severity?: string;
/** The policies the result applies to. Absent for results about quads that no policy reaches. */
policies?: string[];
}

/**
Expand Down Expand Up @@ -92,4 +94,4 @@ export interface IODRLTestCaseValidator {
* Fails or reports mismatch according to test runner logic.
*/
validateTestCase(testCase: ODRLTestCase): Promise<TestCaseResult>;
}
}
332 changes: 250 additions & 82 deletions src/Validator.ts

Large diffs are not rendered by default.

306 changes: 191 additions & 115 deletions src/profiles/Profile.ts

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/shapes/Shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export const SHAPES: string = `@prefix odrl: <http://www.w3.org/ns/odrl/2/> .
<http://example.com/PermissionShape> a sh:NodeShape ;
sh:targetClass odrl:Permission ;
sh:property [
sh:message "A Permission must be referenced by a Policy through odrl:permission." ;
sh:path [
sh:inversePath odrl:permission
] ;
sh:minCount 1
], [
sh:message "A Permission must have one odrl:target." ;
sh:path odrl:target ;
sh:maxCount 1 ;
Expand Down
37 changes: 35 additions & 2 deletions src/shapes/modules/02-odrl-rule.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@
sh:targetClass odrl:Permission ;
sh:node :RuleShape ;

# At least one node points to this permission with odrl:permission
sh:property [
sh:path [ sh:inversePath odrl:permission ] ;
sh:minCount 1 ;
sh:message "A Permission must be referenced through odrl:permission." ;
] ;

sh:property [
sh:path odrl:target ;
sh:minCount 1 ;
Expand All @@ -184,6 +191,13 @@
sh:targetClass odrl:Prohibition ;
sh:node :RuleShape ;

# At least one node points to this prohibition with odrl:prohibition
sh:property [
sh:path [ sh:inversePath odrl:prohibition ] ;
sh:minCount 1 ;
sh:message "A Prohibition must be referenced through odrl:prohibition." ;
] ;

sh:property [
sh:path odrl:target ;
sh:minCount 1 ;
Expand All @@ -205,20 +219,39 @@
sh:message "Each Prohibition remedy must conform to ODRL duty." ;
] .

# Duty = Rule


# Duty = Rule
:DutyShape a sh:NodeShape ;
sh:targetClass odrl:Duty ;
sh:node :RuleShape ;

# At least one node points to this duty with odrl:duty, odrl:consequence, odrl:remedy or odrl:obligation
sh:property [
sh:path [ sh:inversePath [ sh:alternativePath ( odrl:duty odrl:consequence odrl:remedy odrl:obligation ) ] ] ;
sh:minCount 1 ;
sh:message "A Duty must be referenced through odrl:duty, odrl:consequence, odrl:remedy or odrl:obligation." ;
] ;

sh:property [
sh:path odrl:consequence ;
sh:node :DutyShape ;
sh:message "Each Duty consequence must conform to ODRL duty." ;
] .

# Rules for offer
# At least one node points to this duty with odrl:duty, odrl:consequence, odrl:remedy or odrl:obligation
:DutyReferencedShape a sh:NodeShape ;
sh:targetClass odrl:Duty ;
sh:or (
[ sh:path [ sh:inversePath odrl:duty ] ; sh:minCount 1 ]
[ sh:path [ sh:inversePath odrl:consequence ] ; sh:minCount 1 ]
[ sh:path [ sh:inversePath odrl:remedy ] ; sh:minCount 1 ]
[ sh:path [ sh:inversePath odrl:obligation ] ; sh:minCount 1 ]
) ;
sh:message "A Duty must be referenced through odrl:duty, odrl:consequence, odrl:remedy or odrl:obligation." .


# Rules for offer
:OfferPermissionShape a sh:NodeShape ;
sh:node :PermissionShape ;
sh:node :OfferRequiredAssignerShape .
Expand Down
7 changes: 7 additions & 0 deletions src/shapes/odrl-shapes.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@
sh:targetClass odrl:Permission ;
sh:node :RuleShape ;

# At least one policy points to this permission with odrl:permission
sh:property [
sh:path [ sh:inversePath odrl:permission ] ;
sh:minCount 1 ;
sh:message "A Permission must be referenced by a Policy through odrl:permission." ;
] ;

sh:property [
sh:path odrl:target ;
sh:minCount 1 ;
Expand Down
13 changes: 12 additions & 1 deletion src/util/Vocabulary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ export const DETECTION = createVocabulary('https://w3id.org/force/detection#',
)

export const SH = createVocabulary('http://www.w3.org/ns/shacl#',
'NodeShape',
'in',
'inversePath',
'message',
'minCount',
'node',
'or',
'property',
'path',
'targetClass');
'targetClass',
'alternativePath',
'targetSubjectsOf',
'Violation',
'Warning'
);

export const RDF = createVocabulary('http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'Property',
Expand Down
Loading
Loading