Skip to content

Commit 0ca594b

Browse files
committed
added some readme, changed Schema#validate() visibility to public
1 parent bb8b301 commit 0ca594b

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
<img src="https://travis-ci.org/erosb/json-schema-validator.svg?branch=master" />
2-
31
JSON Schema Validator
2+
=====================
3+
4+
This project is an implementation of the [JSON Schema Core Draft v4]("http://json-schema.org/latest/json-schema-core.html") specification.
5+
It uses the [org.json API]("http://www.json.org/java/") for representing JSON data.
6+
7+
Quickstart
8+
----------
9+
10+
```java
11+
import org.everit.jsonvalidator.Schema;
12+
import org.everit.jsonvalidator.loader.SchemaLoader;
13+
import org.json.JSONObject;
14+
import org.json.JSONTokener;
15+
// ...
16+
JSONObject rawSchema = new JSONObject(new JSONTokener(Main.class.getResourceAsStream("/path/to/your/schema.json")));
17+
Schema schema = SchemaLoader.load(rawSchema);
18+
schema.validate(new JSONObject("{\"hello\" : \"world\"}")); // throws a ValidationException if this object is invalid
19+
```
20+
421

core/src/main/java/org/everit/jsonvalidator/ReferenceSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public ReferenceSchema(final Builder builder) {
5353
}
5454

5555
@Override
56-
void validate(final Object subject) {
56+
public void validate(final Object subject) {
5757
if (referredSchema == null) {
5858
throw new IllegalStateException("referredSchema must be injected before validation");
5959
}

core/src/main/java/org/everit/jsonvalidator/Schema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected Schema(final Builder builder) {
7575
/**
7676
* Validates.
7777
*/
78-
abstract void validate(final Object subject);
78+
public abstract void validate(final Object subject);
7979

8080
@Override
8181
public int hashCode() {

0 commit comments

Comments
 (0)