Skip to content

Repository files navigation

@codaco/protocol-validation

This npm package implements methods for validating Network Canvas protocol files against an appropriate JSON schema.

It exports three methods:

  1. validateSchema - validates a schema against the JSON schema
const{ hasErrors, errors }=validateSchema(schemaJson);
  1. validateLogic - validates the logic of the protocol to ensure there are no inconsistencies. This includes validations that cannot be implemented within the JSON schema.
const{ hasErrors, errors }=validateLogic(protocolJson);
  1. validateProtocol - validates the protocol against the schema and logic.
try{validateProtocol(protocolJson,schemaJson);// schema is valid}catch(e){if(einstanceofValidationError){// schema is invalid. e.schemaErrors and e.dataErrors contain the errors}else{// some other error happened during the process}}

It also exports migration functionality for migrating protocols from one version to another.

constmigratedProtocol=migrateProtocol(8,protocolJson);

About

Submodule implementing protocol schema validation

Resources

Stars

0 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages