Schema: robos:GherkinRule

Formal W3C SHACL constraint shape and OSLC JSON-LD specification for robos:GherkinRule in the testing package store.

Table of contents

  1. Specification Metadata
  2. Upstream Schema Basis (Refers From) & Global Standards Provenance
  3. Entity Relationship & Schema Context
  4. Property Constraints & SHACL Rules
  5. Canonical OSLC JSON-LD Example
  6. Programmatic SHACL Validation

Specification Metadata


Upstream Schema Basis (Refers From) & Global Standards Provenance

This RobOS schema is modeled after and directly aligns with two levels of global standards:


Entity Relationship & Schema Context

Gherkin Rule robos:GherkinRule

Governed by W3C SHACL shape urn:robos:shape:GherkinRuleShape within the Testing, Quality & BDD (robos.testing) (robos.testing) package store.

dcterms:title robos:inFeature

Property Constraints & SHACL Rules

Property Path Name Multiplicity Data Type Constraint Rule / Validation Message
dcterms:title Title / Display Name 1..* xsd:string Gherkin Rule must have a title.
robos:inFeature inFeature 1..* xsd:string Gherkin Rule must link to parent Gherkin feature.

Canonical OSLC JSON-LD Example

{
  "@id": "urn:robos:gherkin:checkout-cart-validation:rule-inventory",
  "@type": [
    "robos:GherkinRule",
    "robos:Rule",
    "schema:DigitalDocument"
  ],
  "dcterms:title": "Rule: Inventory must be verified before payment processing",
  "dcterms:description": "Transactions fail early if any cart item quantity exceeds available stock warehouse ledger.",
  "robos:inFeature": "urn:robos:gherkin:checkout-cart-validation",
  "robos:package": "testing",
  "robos:namespace": "robos.testing",
  "robos:refersFrom": "https://cucumber.io/docs/gherkin/reference/#rule",
  "robos:schemaOrgType": "https://schema.org/DigitalDocument",
  "robos:domainStandard": "https://cucumber.io/docs/gherkin/reference/#rule"
}

Programmatic SHACL Validation

const { SHACLValidator } = require('/usr/local/share/robos/robos-graph/lib/shacl-validator');
const { OSLCGraphParser, OSLC_CONTEXT } = require('/usr/local/share/robos/robos-graph/lib/oslc-parser');

const validator = new SHACLValidator();
const result = validator.validateGraph(new OSLCGraphParser({
  "@context": OSLC_CONTEXT,
  "robos:nodes": [
    {
        "@id": "urn:robos:gherkin:checkout-cart-validation:rule-inventory",
        "@type": [
            "robos:GherkinRule",
            "robos:Rule",
            "schema:DigitalDocument"
        ],
        "dcterms:title": "Rule: Inventory must be verified before payment processing",
        "dcterms:description": "Transactions fail early if any cart item quantity exceeds available stock warehouse ledger.",
        "robos:inFeature": "urn:robos:gherkin:checkout-cart-validation",
        "robos:package": "testing",
        "robos:namespace": "robos.testing",
        "robos:refersFrom": "https://cucumber.io/docs/gherkin/reference/#rule",
        "robos:schemaOrgType": "https://schema.org/DigitalDocument",
        "robos:domainStandard": "https://cucumber.io/docs/gherkin/reference/#rule"
    }
  ],
}));

console.log("Conforms:", result.conforms); // Expected: true