This script validates a JSON file against the DCAT-US Schema (v1) and outputs any validation errors in a validation-errors.json file.
Install dependencies:
npm installRun the script by providing the path to the JSON file you want to validate:
node validate-dcat.js {input-file-path}Example:
node validate-dcat.js ./data/dcat-file.json- If the file is valid: A success message will be logged, and no errors will be written.
- If the file is invalid: The script will log the errors, and a
validation-errors.jsonfile will be generated containing the following structure:
{
"isValid": false,
"amount": "<number_of_errors>",
"errors": [
{
"dataPath": "<path_to_invalid_data>",
"message": "<error_message>",
"datasetIdentifier": "<dataset_identifier_if_applicable>"
}
]
}- Updated GSA DCAT-US Schema to draft-07 from draft-04 to keep inline with GSA's schema.
- Did not keep validation for "REDACTED" values.