public abstract class KeywordValidator extends Object
In the processing order, a keyword validator is only called after the
schema has been deemed syntactically valid: this is why it is practically
a requirement that if you create a new validating keyword, you pair it with
a SyntaxChecker. The constructor will be all the more simple as a
result.
A keyword only takes effect for a certain number of JSON instance types: if the instance to validate is not among these types, validation succeeds.
Two other abstract classes exist which you may want to extend instead of this one, depending on your needs:
NumericKeywordValidator, for validating numeric instances;
PositiveIntegerKeywordValidator, for keywords accepting
only a positive integer as an argument (to be paired with PositiveIntegerSyntaxChecker).| Modifier and Type | Field and Description |
|---|---|
private EnumSet<NodeType> |
instanceTypes
What types this keyword validates
|
protected String |
keyword
The keyword
|
| Modifier | Constructor and Description |
|---|---|
protected |
KeywordValidator(String keyword,
NodeType... types)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
abstract String |
toString() |
protected abstract void |
validate(ValidationContext context,
ValidationReport report,
JsonNode instance)
Method which all keyword validators must implement
|
void |
validateInstance(ValidationContext context,
ValidationReport report,
JsonNode instance)
Main validation function
|
protected final String keyword
public final void validateInstance(ValidationContext context, ValidationReport report, JsonNode instance)
Its only role is to check whether the instance type is recognized
by this keyword. If so, it calls validate(ValidationContext,
ValidationReport, JsonNode).
context - the contextreport - the validation reportinstance - the instance to validateprotected abstract void validate(ValidationContext context, ValidationReport report, JsonNode instance)
context - the contextreport - the validation reportinstance - the instance to validateCopyright © 2012. All Rights Reserved.