npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

odrl-validator

v0.1.0

Published

Validating ODRL policies regarding syntax, semantics and consistency

Downloads

160

Readme

ODRL Validator

The ODRL Validator is a Typescript tool to aid development of consistent ODRL policies. This means the tool can validate whether the policies are syntactically (the correct syntax using the ODRL Vocabulary) and semantically (the terms are used in the correct place according to the model) correct. Furthermore, the tool can detect whether the policies do not contain inconsistencies, that is do they contain two or more rules that contradict each other.

An online version of the ODRL Validator can be found here.

Architecture

ODRL Validator

flowchart LR
    Policies["Set of ODRL Policies"]

    subgraph ODRLValidator["ODRL Validator"]
        Atomization --> Validation
        Validation["ODRL Validation\n(Syntactic & Semantic)"]
        ConflictDetection["Conflict Detection"]
        Validation --> ConflictDetection
    end

    Output["Output\n(Validation Results & Conflicts)"]

    Policies --> ODRLValidator
    ODRLValidator --> Output

Running the ODRL Validator

The following example demonstrates how to parse a policy and run the validator.

import { ODRLValidator } from "odrl-validator";
import { Parser } from "n3";

const policyText = `
    @prefix odrl: <http://www.w3.org/ns/odrl/2/> .
    @prefix ex:   <http://example.org/> .

    ex:policy
        a odrl:Policy ;
        odrl:permission  ex:permissionRule ;
        odrl:prohibition ex:prohibitionRule .

    ex:permissionRule
        a odrl:Permission ;
        odrl:target   ex:resource ;
        odrl:assignee ex:alice ;
        odrl:action   odrl:use .

    ex:prohibitionRule
        a odrl:Prohibition ;
        odrl:target   ex:resource ;
        odrl:assignee ex:alice ;
        odrl:action   odrl:use .
        
    ex:alice a odrl:Party .
    ex:resource a odrl:Asset .
  `;

const quads = parser.parse(policyText);
const validator = new ODRLValidator();
const results = await validator.validate(quads);

console.log(results);

The validator operates in two stages:

  1. SHACL validation
    The input policy is first checked against the ODRL information model using SHACL constraints.
  2. Conflict detection
    If the policy passes validation (i.e. no violations), conflict detection is performed.
    Currently, this step focuses on identifying deontic conflicts.

Therefore the output of the validate function (ValidatorResult) contains three fields:

  • valid: true iff no SHACL violations were found
  • validationResults: SHACL outcomes
    • Warning: Indicates a potential issue, but does not invalidate the policy.
    • Violation: Indicates an error against the ODRL information model.
  • conflicts: detected inconsistencies
    • message: describes the reason for the conflict
    • It also identifies the two rules involved (ruleA and ruleB)

In the future, we want to include more kinds of conflicts:

  • Lex Specialis
  • constraint/refinement similarity
  • correct constraint operator detection

Comments

  • uid property
    • In JSON-LD, ODRL’s uid is mapped to @id to uniquely identify policies or rules. (Victors policy do not have this property)
    • suggestion: In Turtle (TTL), this mapping isn’t required, so uid can be omitted while still remaining ODRL-compliant.

Feedback and questions

Do not hesitate to report a bug.

Further questions can also be asked to Wout Slabbinck or Elena Molino (developers and maintainers of this repository).