Developer Guide¶
Javascript Validator¶
The source code for all versions of the Psych-DS Validator derives from our Deno-based CLI app, which was modeled after the BIDS Deno validator. It is available via npm without any additional downloads, and can be used either through the CLI, within a node application, or as a browser bundle.
Using the CLI app¶
The easiest way to install the app is via npm. Simply install the package globally with the following command:
NPM Installation
npm install -g psychds-validator
This will allow you to use the validate command:
NPM Usage
validate <path_to_dataset>
Optional parameters¶
The following parameters and flags can be appended to the validate command to modify the validator's behavior:
Parameters
-wor--showWarnings: causes the validator to output warnings and suggestions for best practices in addition to any errors.--useEvents: switches the validator to display the output as a sequential progress checklist instead of a collection of issues. Only reports the first error it encounters in the sequence--json: causes the validator to return the validation results as a JSON rather than printing them to the log.-sor--schema: switches the validator to use a different version of the Psych-DS schema. Default is "latest".
Using the validate function within a node app¶
To use the validate function within server-side javascript, the installation is the same as above. Then, within your app, you can import and use "validate" as so:
For CJS Contexts
const { validate } = require("psychds-validator");
For ESM Contexts
import { validate } from "psychds-validator";
Then the validate function can be used with any of the optional flags:
Node Usage
const result = await validate("<path_to_example_dataset>",{'exampleOption':true});