Developed in support of collecting and validating metadata but can be used for validating JSON configuration files for analysis pipelines as well.
Projects should use the Draft7
specification: https://json-schema.org/draft-07/json-schema-release-notes
$schema
should be set tohttp://json-schema.org/draft-07/schema#
as follows:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {},
"requried": []
}
Python projects should use the NIAGADS-pylib to leverage our customized Draft7Validator as follows:
from niagads.validators import JSONValidator
schemaFile = "schema.json" # file defining the JSON schema against which the JSON is to be validated
jsonObj = {"id": 2, ...} # JSON object to be validated
validator = JSONValidator(jsonObj, schemaFile)
validator.run() # returns True if jsonObj passes validation; a list of ValidationErrors otherwise
This validator extends the Draft7 specification to support the following field formats:
- DOI (doi)
- PUBMED ID (pubmed_id)
- md5sum (md5sum)
See the documentation for more information