Skip to content

Latest commit

 

History

History

validator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

JSONx Validator

JSON Schema for the enterprise

Build Status Coverage Status Javadocs Released Version Snapshot Version

Abstract

This document specifies the JSONx Validator, which offers facilities for validating JSON documents agains a JSD schema.

Table of Contents

  1 Introduction
    1.1 Conventions Used in This Document
  2 Purpose
  3 Requirements
  4 Getting Started
    4.1 Valid Case
    4.2 Invalid Case
  5 Specification
  6 Contributing
  7 Special Thanks
  8 License

1 Introduction

This document presents the functionality of the JSONx Validator. It also contains a directory of links to these related resources.

The JSONx Validator consumes a JSD schema and a JSON document, and returns successfully if the specified documents are valid against the provided schema, or fails with an exception specifying the validation error if the specified document is invalid against the provided schema. The JSONx Validator utilizes the JSONx Binding Generator to perform its validation.

1.1 Conventions Used in This Document

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC2119.

2 Purpose

Provide a validator utility for automatic validation of JSON documents against a schema document.

3 Requirements

  1. The validator MUST be able to consume a JSON document, and validate its contents agains a provided schema document.

  2. The validator MUST return successfully if a JSON document conforms to the provided schema document.

  3. The validator MUST throw an exception specifying the validation error if a JSON document does not conform to the provided schema document.

4 Getting Started

The JSONx Validator provides convenience utilities for validating a JSON document agains a schema document. The following illustrates example usage of the Validator.

4.1 Valid Case

The following example uses the Validator to validate a valid JSON document against a schema document.

$ java -cp ... org.jsonx.Validator src/main/resources/example.jsd src/main/resources/valid.json
$ echo $?
0

4.2 Invalid Case

The following example uses the Validator to validate an invalid JSON document against a schema document.

$ java -cp ... org.jsonx.Validator src/main/resources/example.jsd src/main/resources/invalid.json
Invalid content was found in empty array: @org.jsonx.StringElement(id=0, pattern="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"): Content is not complete
$ echo $?
1

5 Specification

The Validator is a utility class that can be used on the CLI to validate a JSON document against a schema document. The Validator class has the following usage specification:

Usage: Usage: Validator <SCHEMA> <JSON...>
Supported SCHEMA formats:
                 <JSD|JSDx>

6 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

7 Special Thanks

Java Profiler
Special thanks to EJ Technologies for providing their award winning Java Profiler (JProfiler) for development of the JSONx Framework.

8 License

This project is licensed under the MIT License - see the LICENSE.txt file for details.