-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from joblift/custom-meta-schemas
Support custom meta schemas with custom keywords and formats
- Loading branch information
Showing
53 changed files
with
947 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,44 +13,39 @@ | |
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<project | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.networknt</groupId> | ||
<artifactId>json-schema-validator</artifactId> | ||
<version>0.1.11</version> | ||
<description>A json schema validator that supports draft v4</description> | ||
<url>https://github.com/networknt/json-schema-validator</url> | ||
<name>JsonSchemaValidator</name> | ||
|
||
<developers> | ||
<developer> | ||
<id>stevehu</id> | ||
<name>Steve Hu</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
<issueManagement> | ||
<system>github</system> | ||
<url>https://github.com/networknt/json-schema-validator/issues</url> | ||
</issueManagement> | ||
|
||
<licenses> | ||
<license> | ||
<name>Apache License Version 2.0</name> | ||
<url>http://repository.jboss.org/licenses/apache-2.0.txt</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<connection>scm:git://github.com:networknt/json-schema-validator.git</connection> | ||
<developerConnection>scm:git://github.com:networknt/json-schema-validator.git</developerConnection> | ||
<url>https://github.com:networknt/json-schema-validator.git</url> | ||
</scm> | ||
|
||
<distributionManagement> | ||
<snapshotRepository> | ||
<id>ossrh</id> | ||
|
@@ -61,7 +56,6 @@ | |
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<properties> | ||
<java.version>1.6</java.version> | ||
<java.testversion>1.7</java.testversion> | ||
|
@@ -74,10 +68,7 @@ | |
<version.mockito>2.7.21</version.mockito> | ||
<version.hamcrest>1.3</version.hamcrest> | ||
<version.undertow>1.4.11.Final</version.undertow> | ||
|
||
</properties> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
|
@@ -99,7 +90,6 @@ | |
<artifactId>commons-lang3</artifactId> | ||
<version>${version.common-lang3}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
|
@@ -152,7 +142,6 @@ | |
</includes> | ||
</testResource> | ||
</testResources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.sonatype.plugins</groupId> | ||
|
@@ -166,13 +155,8 @@ | |
</configuration> | ||
</plugin> | ||
<!-- | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-release-plugin</artifactId> | ||
<version>2.5.3</version> | ||
</plugin> | ||
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-release-plugin</artifactId><version>2.5.3</version></plugin> | ||
--> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
|
@@ -221,7 +205,6 @@ | |
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
|
@@ -234,8 +217,6 @@ | |
</dependency> | ||
</dependencies> | ||
</plugin> | ||
|
||
|
||
<!-- JACOCO added for code coverage --> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
|
@@ -261,10 +242,8 @@ | |
</executions> | ||
</plugin> | ||
<!-- end JACOCO --> | ||
|
||
</plugins> | ||
</build> | ||
|
||
<reporting> | ||
<plugins> | ||
<plugin> | ||
|
@@ -274,7 +253,6 @@ | |
</plugin> | ||
</plugins> | ||
</reporting> | ||
|
||
<profiles> | ||
<profile> | ||
<id>release-sign-artifacts</id> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.networknt.schema; | ||
|
||
public abstract class AbstractFormat implements Format{ | ||
private final String name; | ||
private final String errorMessageDescription; | ||
|
||
public AbstractFormat(String name) { | ||
this(name, ""); | ||
} | ||
|
||
public AbstractFormat(String name, String errorMessageDescription) { | ||
this.name = name; | ||
this.errorMessageDescription = errorMessageDescription; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String getErrorMessageDescription() { | ||
return errorMessageDescription; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/networknt/schema/AbstractJsonValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.networknt.schema; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
public abstract class AbstractJsonValidator implements JsonValidator { | ||
private final String keyword; | ||
protected AbstractJsonValidator(String keyword) { | ||
this.keyword = keyword; | ||
} | ||
public Set<ValidationMessage> validate(JsonNode node) { | ||
return validate(node, node, AT_ROOT); | ||
} | ||
|
||
protected ValidationMessage buildValidationMessage(ErrorMessageType errorMessageType, String at, String... arguments) { | ||
return ValidationMessage.of(keyword, errorMessageType, at, arguments); | ||
} | ||
protected ValidationMessage buildValidationMessage(ErrorMessageType errorMessageType, String at, Map<String, Object> details) { | ||
return ValidationMessage.of(keyword, errorMessageType, at, details); | ||
} | ||
|
||
protected Set<ValidationMessage> pass() { | ||
return Collections.emptySet(); | ||
} | ||
|
||
protected Set<ValidationMessage> fail(ErrorMessageType errorMessageType, String at, Map<String, Object> details) { | ||
return Collections.singleton(buildValidationMessage(errorMessageType, at, details)); | ||
} | ||
|
||
protected Set<ValidationMessage> fail(ErrorMessageType errorMessageType, String at, String...arguments) { | ||
return Collections.singleton(buildValidationMessage(errorMessageType, at, arguments)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.networknt.schema; | ||
|
||
|
||
public abstract class AbstractKeyword implements Keyword { | ||
private final String value; | ||
|
||
public AbstractKeyword(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.