Skip to content

Implement DID Document Validation Logic #6

@chrishooooo-netizen

Description

@chrishooooo-netizen

Summary

Build a validation module that checks whether a did:trail DID Document conforms to the TRAIL DID Method specification. This is a core building block for any resolver or verifier implementation.

What needs to happen

  1. Create validation/did-document-validator.js with functions that validate:

    • Required top-level fields (id, controller, verificationMethod, authentication)
    • id format matches did:trail:<namespace>:<unique-id> pattern
    • verificationMethod entries have valid type, controller, and key material (publicKeyJwk or publicKeyMultibase)
    • Service endpoints (if present) have valid id, type, and serviceEndpoint
    • Capability delegation chain structure (delegator → delegate relationship)
  2. Create test fixtures in validation/fixtures/:

    • valid-did-document.json — a fully conformant DID Document
    • invalid-*.json — documents with specific violations (missing fields, wrong key format, malformed ID, etc.)
  3. Create validation/validate.js — a CLI runner that takes a DID Document JSON file and outputs validation results

  4. Add a README.md in validation/ explaining usage and linking to the relevant spec sections

Acceptance criteria

  • Validator catches all required-field violations
  • Validator accepts a fully conformant document without false positives
  • At least 5 test fixtures covering different error cases
  • CLI runner works: node validation/validate.js fixtures/valid-did-document.json
  • Code follows the style established in examples/js/

Context

Labels

help wanted · enhancement

cc @AmeyParle — this follows up on your interest in contributing to core validation logic (see your comment on #4). Would love to have you take this on!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions