-
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.
Improved handling for unknown keywords
- Loading branch information
Klas Kalaß
committed
Nov 22, 2017
1 parent
79acd4d
commit e4a7af3
Showing
3 changed files
with
54 additions
and
4 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
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
33 changes: 33 additions & 0 deletions
33
src/main/java/com/networknt/schema/NonValidationKeyword.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,33 @@ | ||
package com.networknt.schema; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
/** | ||
* Used for Keywords that have no validation aspect, but are part of the metaschema. | ||
*/ | ||
public class NonValidationKeyword extends AbstractKeyword { | ||
|
||
private static final class Validator extends AbstractJsonValidator { | ||
private Validator(String keyword) { | ||
super(keyword); | ||
} | ||
|
||
@Override | ||
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) { | ||
return Collections.emptySet(); | ||
} | ||
} | ||
|
||
public NonValidationKeyword(String keyword) { | ||
super(keyword); | ||
} | ||
|
||
@Override | ||
public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, | ||
ValidationContext validationContext) throws JsonSchemaException, Exception { | ||
return new Validator(getValue()); | ||
} | ||
} |