Skip to content

NIAGADS/metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JSON Schemas for JSON Validation

Developed in support of collecting and validating metadata but can be used for validating JSON configuration files for analysis pipelines as well.

Requirements for NIAGADS JSON Schemas:

Projects should use the Draft7 specification: https://json-schema.org/draft-07/json-schema-release-notes

$schema should be set to http://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

Useful Documentation to help write JSON Schemas

Introduction

conditionals

built-in formats for validation