Skip to content

description: Get started with dppvalidator in 5 minutes.

Quick Start

Get started with dppvalidator in 5 minutes.

1. Install dppvalidator

Text Only
```
uv add dppvalidator
```
Text Only
```
pip install dppvalidator
```

2. Create a Sample DPP

Create a file called passport.json:

JSON
{
  "id": "https://example.com/dpp/battery-001",
  "type": ["DigitalProductPassport", "VerifiableCredential"],
  "issuer": {
    "id": "https://example.com/manufacturer",
    "name": "Acme Battery Co."
  },
  "credentialSubject": {
    "id": "https://example.com/product/battery-001",
    "product": {
      "id": "https://example.com/product/battery-001",
      "name": "EV Battery Pack",
      "description": "High-capacity lithium-ion battery for electric vehicles"
    }
  }
}

3. Validate from Command Line

Text Only
dppvalidator validate passport.json

Output:

Text Only
✓ VALID: passport.json
Schema version: 0.6.1
Validation time: 1.23ms

4. Validate Programmatically

Python
from dppvalidator.validators import ValidationEngine

# Create validation engine
engine = ValidationEngine()

# Load and validate
with open("passport.json") as f:
    import json

    data = json.load(f)

result = engine.validate(data)

# Check result
print(f"Valid: {result.valid}")
print(f"Errors: {len(result.errors)}")
print(f"Warnings: {len(result.warnings)}")

5. Handle Validation Errors

Python
result = engine.validate({"id": "invalid"})

if not result.valid:
    for error in result.errors:
        print(f"[{error.code}] {error.path}: {error.message}")

6. Export to JSON-LD

Python
from dppvalidator.exporters import JSONLDExporter
from dppvalidator.models import DigitalProductPassport, CredentialIssuer

# Create a passport
passport = DigitalProductPassport(
    id="https://example.com/dpp/001",
    issuer=CredentialIssuer(id="https://example.com/issuer", name="Acme Corp"),
)

# Export to JSON-LD
exporter = JSONLDExporter()
jsonld = exporter.export(passport)
print(jsonld)

7. Working with UNTP v0.7.0

dppvalidator supports both UNTP DPP v0.6.x (the wire shape used above — credentialSubject wraps a Product) and v0.7.0 (credentialSubject IS the Product directly, with new required fields). The engine auto-detects the version from the payload's @context URL.

Validate a v0.7.0 payload

Bash
# Auto-detected from the payload's @context URL.
dppvalidator validate passport-v07.json

# Pin explicitly when you want VER001 fail-fast on mismatched payloads.
dppvalidator validate passport-v07.json --schema-version 0.7.0

Upgrade a v0.6.x payload to v0.7.0

Bash
# Write the upgraded payload to a new file.
dppvalidator migrate passport.json -o passport-v07.json

# Validate-after-upgrade in one shot.
dppvalidator validate passport.json \
    --upgrade-from 0.6.1 \
    --schema-version 0.7.0

The shim emits structured warnings (UPG001UPG004) for fields it can't fully translate. See the migration guide for the field rename table and warning codes, and UNTP DPP versions for the full version-handling story.

Next Steps

For AI Assistants

If you're an LLM or AI assistant, see our machine-readable context files: