Skip to content

metadatacenter/cedar-model-validation-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CEDAR Model Validation Library

Provides a Java-based CEDAR library to validate JSON Schema-encoded CEDAR schema artifacts (templates, elements, and fields) and JSON-LD-encoded instance artifacts (template instances).

Also provides command line Java- and Python-based validators

Validation Library

The library provides an interface org.metadatacenter.model.validation.ModelValidator that contains methods to validate CEDAR artifacts, such as, templates, elements, fields, and template instances.

Generate Validation Schemas

The schema directory contains a collection of JSON Schema-encoded specifications, which collectively form the CEDAR Metamodel Schema. We designed the schema definitions to be modular for easy development and reuse.

These specificartions are assembled into meta-sechemas to validate templates, elements and fields.

The CedarValidator uses these validation meta-schemas. They are stored in the Java resources directory. To generate these meta-schemas we need to merge the invidiual schemas in the schema directory and assemble them into several standalone self-contained meta-schemas. We have provided a script to do this assembly in the scripts directory.

cd scripts
./generate-meta-schemas.sh

The script will generate six meta-schema files (template-meta-schema.json, element-meta-schema.json, literal-field-meta-schema.json, iri-field-meta-schema.json, static-field-meta-schema.json, and multi-instance-field-meta-schema.json) in the src/main/resources directory.

The description about the components to generate each meta-schema can be found in the YAML files in schema directory.

Command Line Validation in Java

Below are some command-line examples validate templates, elements, fields, and instances.

mvn exec:java@validate-template -Dexec.args="./src/test/resources/templates/empty-template.json"
mvn exec:java@validate-template -Dexec.args="./src/test/resources/templates/single-field-template.json"
mvn exec:java@validate-template -Dexec.args="./src/test/resources/templates/multi-field-template.json"
mvn exec:java@validate-element -Dexec.args="./src/test/resources/elements/empty-element.json"
mvn exec:java@validate-element -Dexec.args="./src/test/resources/elements/many-fields-element.json"
mvn exec:java@validate-field -Dexec.args="./src/test/resources/fields/text-field.json"
mvn exec:java@validate-field -Dexec.args="./src/test/resources/fields/constrained-text-field.json"
mvn exec:java@validate-instance -Dexec.args="./src/test/resources/templates/template-allowing-annotations.json ./src/test/resources/instances/instance-with-annotations.jsonld"

Command Line Validation in Python

Below are some examples to validate using Python jsonschema implementation (required Python 3.x).

cd scripts
./validate-template.sh ../src/test/resources/templates/empty-template.json
./validate-template.sh ../src/test/resources/templates/single-field-template.json
./validate-template.sh ../src/test/resources/templates/multi-field-template.json
./validate-element.sh ../src/test/resources/elements/empty-element.json
./validate-element.sh ../src/test/resources/elements/multi-field-element.json
./validate-field.sh ../src/test/resources/fields/text-field.json
./validate-field.sh ../src/test/resources/fields/constrained-text-field.json

Questions

If you have questions about this repository, please subscribe to the CEDAR Developer Support mailing list. After subscribing, send messages to cedar-developers at lists.stanford.edu.

About

Library for validating all CEDAR model artifacts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •