Package dev.harrel.jsonschema
Class FormatEvaluatorFactory
java.lang.Object
dev.harrel.jsonschema.FormatEvaluatorFactory
- All Implemented Interfaces:
EvaluatorFactory
EvaluatorFactory implementation that provides format validation capabilities.
It should not be used as a standalone factory.
It is intended to be used as a supplementary factory to a full dialect-compatible factory (like Draft2020EvaluatorFactory).
new ValidatorFactory().withEvaluatorFactory(new FormatEvaluatorFactory());
May also be used in conjunction with custom factories:
new ValidatorFactory().withEvaluatorFactory(EvaluatorFactory.compose(customFactory, new FormatEvaluatorFactory()));
It may not be fully compatible with JSON Schema specification. It is mostly based on tools already present in JDK itself. Supported formats:
-
date, date-time, time - uses
DateTimeFormatterwith standard ISO formatters, -
duration - regex based validation as it may be combination of
DurationandPeriod, -
email, idn-email - uses
JMail.isValid(String), - hostname - regex based validation,
- idn-hostname - not supported - performs same validation as hostname,
-
ipv4, ipv6 - uses
InternetProtocolAddress, -
uri, uri-reference, iri, iri-reference - uses
URI, -
uuid - uses
UUID, - uri-template - lenient checking of unclosed braces (should be compatible with Spring's implementation),
- json-pointer, relative-json-pointer - manual validation,
-
regex - uses
Pattern.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.harrel.jsonschema.EvaluatorFactory
EvaluatorFactory.Builder -
Constructor Summary
ConstructorsConstructorDescriptionCreates a default instance without vocabularies support.FormatEvaluatorFactory(Set<String> vocabularies) Creates a customized instance with vocabularies support. -
Method Summary
-
Constructor Details
-
FormatEvaluatorFactory
public FormatEvaluatorFactory()Creates a default instance without vocabularies support. -
FormatEvaluatorFactory
Creates a customized instance with vocabularies support. Validation will only be run when at least one of provided vocabularies is active during validation process.
-
-
Method Details
-
create
Description copied from interface:EvaluatorFactoryThis method will be invoked for each JSON object field during schema parsing process. Must not throw any exceptions.- Specified by:
createin interfaceEvaluatorFactory- Parameters:
ctx- current schema parsing contextfieldName- field name (keyword) in JSON object for whichEvaluatorshould be createdfieldNode- value of field in JSON object- Returns:
- If this factory supports given field name (keyword) it should return corresponding
Evaluatorwrapped inOptional,Optional.empty()otherwise.
-