Package com.networknt.schema.format
Interface Format
- All Known Implementing Classes:
AbstractRFC3986Format,DateFormat,DateTimeFormat,DurationFormat,EmailFormat,IdnEmailFormat,IdnHostnameFormat,IPv6Format,IriFormat,IriReferenceFormat,PatternFormat,RegexFormat,TimeFormat,UriFormat,UriReferenceFormat
public interface Format
Used to implement the various formats for the format keyword.
Simple implementations need only override matches(ExecutionContext, String).
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringGets the message key to use for the message.getName()Gets the format name.default booleanmatches(ExecutionContext executionContext, SchemaContext schemaContext, com.fasterxml.jackson.databind.JsonNode value) Determines if the value matches the format.default booleanmatches(ExecutionContext executionContext, SchemaContext schemaContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean assertionsEnabled, FormatValidator formatValidator) Determines if the value matches the format.default booleanmatches(ExecutionContext executionContext, SchemaContext schemaContext, String value) Determines if the value matches the format.default booleanmatches(ExecutionContext executionContext, String value) Determines if the value matches the format.default voidvalidate(ExecutionContext executionContext, SchemaContext schemaContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean assertionsEnabled, Supplier<MessageSourceError.Builder> message, FormatValidator formatValidator) Validates the format.
-
Method Details
-
getName
String getName()Gets the format name.- Returns:
- the format name as referred to in a json schema format node.
-
getMessageKey
Gets the message key to use for the message.See jsv-messages.properties.
The following are the arguments.
{0} The format name
{1} The input valueNote that the default localized messages do not use the input value.
- Returns:
- the message key
-
matches
Determines if the value matches the format.This should be implemented for string node types.
- Parameters:
executionContext- the execution contextvalue- to match- Returns:
- true if matches
-
matches
default boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, String value) Determines if the value matches the format.- Parameters:
executionContext- the execution contextschemaContext- the schema contextvalue- to match- Returns:
- true if matches
-
matches
default boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, com.fasterxml.jackson.databind.JsonNode value) Determines if the value matches the format.- Parameters:
executionContext- the execution contextschemaContext- the schema contextvalue- to match- Returns:
- true if matches
-
matches
default boolean matches(ExecutionContext executionContext, SchemaContext schemaContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean assertionsEnabled, FormatValidator formatValidator) Determines if the value matches the format.This can be implemented for non-string node types.
- Parameters:
executionContext- the execution contextschemaContext- the schema contextnode- the noderootNode- the root nodeinstanceLocation- the instance locationassertionsEnabled- if assertions are enabledformatValidator- the format validator- Returns:
- true if matches
-
validate
default void validate(ExecutionContext executionContext, SchemaContext schemaContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, NodePath instanceLocation, boolean assertionsEnabled, Supplier<MessageSourceError.Builder> message, FormatValidator formatValidator) Validates the format.This is the most flexible method to implement.
- Parameters:
executionContext- the execution contextschemaContext- the schema contextnode- the noderootNode- the root nodeinstanceLocation- the instance locaitonassertionsEnabled- if assertions are enabledmessage- the message builderformatValidator- the format validator
-