GithubHelp home page GithubHelp logo

clivern / decoy Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 476 KB

๐Ÿ”ฅ JSON Schema Validation Package for Java.

License: Apache License 2.0

Java 98.22% Makefile 1.78%
schema-validation schema-validator java-validation-framework json-schema json-schema-validator api-validator java

decoy's Introduction

Decoy Logo

Decoy

JSON Schema Validation Package for Java.

Decoy is a Java implementation for the JSON Schema Standard (draft-03, draft-04, draft-06 and draft-07), that will help you validate all sorts of JSON documents, whether they are configuration files or a set of data sent to a RESTful API endpoint.

Documentation

Installation

To add a dependency using Maven, use the following:

<dependency>
    <groupId>com.clivern</groupId>
    <artifactId>decoy</artifactId>
    <version>0.1.0</version>
</dependency>

To add a dependency using Gradle, use the following:

dependencies {
    compile 'com.clivern:decoy:0.1.0'
}

To add a dependency using Scala SBT, use the following:

libraryDependencies += "com.clivern" % "decoy" % "0.1.0"

Usage

First import & initialize all required classes.

import com.clivern.decoy.util.FileReader;
import com.clivern.decoy.SchemaFactory;
import com.clivern.decoy.Validator;


FileReader fileReader = new FileReader();
SchemaFactory schemaFactory = new SchemaFactory();
Validator validator = new Validator();

Then validate the JSON string against the JSON Schema.

import com.clivern.decoy.SchemaDraft3;


// For SchemaDraft3
SchemaDraft3 schemaDraft3 = schemaFactory.unserialize(
    fileReader.readFileAsString("path/to/endpoint/schema03_definition.json"),
    SchemaDraft3.class
);

validator.validate(schemaDraft3, "{...JSON_DATA_HERE...}");  // returns Boolean (true || false)
validator.hasErrors();                                       // returns Boolean (true || false)
validator.getErrors();                                       // returns ArrayList<String>
import com.clivern.decoy.SchemaDraft4;


// For SchemaDraft4
SchemaDraft4 schemaDraft4 = schemaFactory.unserialize(
    fileReader.readFileAsString("path/to/endpoint/schema04_definition.json"),
    SchemaDraft4.class
);

validator.validate(schemaDraft4, "{...JSON_DATA_HERE...}");  // returns Boolean (true || false)
validator.hasErrors();                                       // returns Boolean (true || false)
validator.getErrors();                                       // returns ArrayList<String>
import com.clivern.decoy.SchemaDraft6;


// For SchemaDraft6
SchemaDraft6 schemaDraft6 = schemaFactory.unserialize(
    fileReader.readFileAsString("path/to/endpoint/schema06_definition.json"),
    SchemaDraft6.class
);

validator.validate(schemaDraft6, "{...JSON_DATA_HERE...}");  // returns Boolean (true || false)
validator.hasErrors();                                       // returns Boolean (true || false)
validator.getErrors();                                       // returns ArrayList<String>
import com.clivern.decoy.SchemaDraft7;


// For SchemaDraft7
SchemaDraft7 schemaDraft7 = schemaFactory.unserialize(
    fileReader.readFileAsString("path/to/endpoint/schema07_definition.json"),
    SchemaDraft7.class
);

validator.validate(schemaDraft7, "{...JSON_DATA_HERE...}");  // returns Boolean (true || false)
validator.hasErrors();                                       // returns Boolean (true || false)
validator.getErrors();                                       // returns ArrayList<String>

Examples

#

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, Decoy is maintained under the Semantic Versioning guidelines and release process is predictable and business-friendly.

See the Releases section of our GitHub project for changelogs for each release version of Decoy. It contains summaries of the most noteworthy changes made in each release.

Bug tracker

If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clivern/decoy/issues

Security Issues

If you discover a security vulnerability within Decoy, please send an email to [email protected]

Contributing

We are an open source, community-driven project so please feel free to join us. see the contributing guidelines for more details.

License

ยฉ 2019, Clivern. Released under Apache License, Version 2.0.

Decoy is authored and maintained by @Clivern.

decoy's People

Contributors

clivern avatar renovate[bot] avatar

Watchers

 avatar  avatar

decoy's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/setup-java v1
gradle
settings.gradle
build.gradle
  • com.diffplug.gradle.spotless 3.30.0
  • com.google.code.gson:gson 2.8.9
  • commons-validator:commons-validator 1.7
  • org.json:json 20211205
  • junit:junit 4.13.2
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 6.9.1

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Support different string formats

  • date_time
  • time
  • date
  • email
  • idn_email
  • hostname
  • idn_hostname
  • ipv4
  • ipv6
  • uri
  • uri_reference
  • iri
  • iri_reference
  • uri_template
  • json_pointer
  • relative_json_pointer
  • regex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.