Skip to content

doc-detective/doc-detective-common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doc Detective Common

Current version NPM Shield Discord Shield

Shared resources for Doc Detective projects.

Install

npm i doc-detective-common

Init

const common = require("doc-detective-common");

Methods

.validate(schemaKey: string, object: object)

Validate that object matches the specified schema definition.

Returns an object with the following schema:

{
  "valid": boolean,
  "errors": [
    {
      "instancePath": string,
      "schemaPath": string,
      "keyword": string,
      "params": [{Object}],
      "message": string
    }
  ]
}

Usage

const schemaKey = "runShell_v1";
const object = {
  action: "runShell",
  command: "echo $username",
};
console.log(common.validate(schemaKey, object));

Objects

.schemas

JSON schema definitions for various objects used throughout Doc Detective.

Schema objects are located in the /schemas directory and made available through the .schemas object.

{
  "analytics_v1": {Object},
  "checkLink_v1": {Object},
  "click_v1": {Object},
  "find_v1": {Object},
  "goTo_v1": {Object},
  "httpRequest_v1": {Object},
  "matchText_v1": {Object},
  "moveMouse_v1": {Object},
  "runShell_v1": {Object},
  "screenshot_v1": {Object},
  "scroll_v1": {Object},
  "startRecording_v1": {Object},
  "stopRecording_v1": {Object},
  "type_v1": {Object},
  "wait_v1": {Object}
}