Quickstart

    Three minutes from a fresh terminal to a validating PDTF transaction in JavaScript.

    1. Install

    npm install @pdtf/schemas

    The package bundles the base transaction schema, all 18 main overlays, and the 16 NTS2 extension overlays. ~1 MB installed.

    2. Get a merged schema

    Pick the overlays your use case needs (here: BASPI v5 for an estate-agent product):

    const { getTransactionSchema } = require('@pdtf/schemas');
    
    const schema = getTransactionSchema(
      'https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json',
      ['baspi5']
    );

    Under the hood, getTransactionSchema deep-merges the base transaction schema with each named overlay. See Schema composition for the merge rules.

    3. Validate

    const { getValidator } = require('@pdtf/schemas');
    
    const validate = getValidator(
      'https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json',
      ['baspi5']
    );
    
    const transaction = require('./my-transaction.json');
    if (validate(transaction)) {
      console.log('Valid');
    } else {
      console.error(validate.errors);
    }

    getValidator returns an Ajv-compiled validator function with all the right keywords (format, discriminator, etc.) configured. validate.errors follows the standard Ajv error format.

    4. Multiple overlays

    Compose several overlays — they merge cumulatively:

    // A conveyancer reviewing a leasehold sale
    const schema = getTransactionSchema(baseId, [
      'baspi5', 'ta6', 'ta7', 'ta10', 'lpe1'
    ]);

    5. Extension overlays

    The NTS2 extension overlays let you compose specific sub-features piecemeal — for a staged NTS → NTS2 migration, you can add just Japanese knotweed and transfer fees:

    const schema = getTransactionSchema(baseId, ['nts2023', 'jk', 'tf']);

    The full list of overlay aliases is in the PDTF overlays page.

    6. Example transactions

    Sample transactions are at source/03-standards/schemas/src/examples/v3/. Worth running through your validator as a first sanity check.

    Where next

    • Schema composition — for the deep-merge mechanics and gotchas (custom arrayMerge, required handling, oneOf conditionals)
    • Validation — for Ajv configuration, error decoding, validating verified claims
    • Verified claims — for signing transaction fragments as W3C VCs
    • The repo's schemas/README.md and CLAUDE.md for developer-friendly walkthroughs

    Comments

    Loading comments…