Package com.networknt.schema
Interface Format
- All Known Implementing Classes:
AbstractFormat
,AbstractRFC3986Format
,BaseFormat
,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 String
Deprecated.default String
Gets the message key to use for the message.getName()
Gets the format name.default boolean
matches
(ExecutionContext executionContext, ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode value) Determines if the value matches the format.default boolean
matches
(ExecutionContext executionContext, ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, FormatValidator formatValidator) Determines if the value matches the format.default boolean
matches
(ExecutionContext executionContext, ValidationContext validationContext, String value) Determines if the value matches the format.default boolean
matches
(ExecutionContext executionContext, String value) Determines if the value matches the format.default Set
<ValidationMessage> validate
(ExecutionContext executionContext, ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, Supplier<MessageSourceValidationMessage.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 instance location
{1} The format name
{2} The error message description
{3} The input value- Returns:
- the message key
-
getErrorMessageDescription
Deprecated.Gets the error message description.Deprecated. Override getMessageKey() and set the localized message in the resource bundle or message source.
- Returns:
- the error message description.
-
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, ValidationContext validationContext, String value) Determines if the value matches the format.- Parameters:
executionContext
- the execution contextvalidationContext
- the validation contextvalue
- to match- Returns:
- true if matches
-
matches
default boolean matches(ExecutionContext executionContext, ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode value) Determines if the value matches the format.- Parameters:
executionContext
- the execution contextvalidationContext
- the validation contextvalue
- to match- Returns:
- true if matches
-
matches
default boolean matches(ExecutionContext executionContext, ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, JsonNodePath 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 contextvalidationContext
- the validation contextnode
- the noderootNode
- the root nodeinstanceLocation
- the instance locationassertionsEnabled
- if assertions are enabledformatValidator
- the format validator- Returns:
- true if matches
-
validate
default Set<ValidationMessage> validate(ExecutionContext executionContext, ValidationContext validationContext, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, JsonNodePath instanceLocation, boolean assertionsEnabled, Supplier<MessageSourceValidationMessage.Builder> message, FormatValidator formatValidator) Validates the format.This is the most flexible method to implement.
- Parameters:
executionContext
- the execution contextvalidationContext
- the validation contextnode
- the noderootNode
- the root nodeinstanceLocation
- the instance locaitonassertionsEnabled
- if assertions are enabledmessage
- the message builderformatValidator
- the format validator- Returns:
- the messages
-