Package org.everit.json.schema
Interface FormatValidator
-
- All Known Implementing Classes:
DateFormatValidator
,DateTimeFormatValidator
,EmailFormatValidator
,HostnameFormatValidator
,IPV4Validator
,IPV6Validator
,JsonPointerFormatValidator
,RegexFormatValidator
,RelativeJsonPointerFormatValidator
,TemporalFormatValidator
,TimeFormatValidator
,URIFormatValidator
,URIReferenceFormatValidator
,URITemplateFormatValidator
,URIV4FormatValidator
,WrappingFormatValidator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface FormatValidator
Implementations perform the validation against the "format" keyword (see JSON Schema spec section 7).
-
-
Field Summary
Fields Modifier and Type Field Description static FormatValidator
NONE
No-operation implementation (never throws {always returnsOptional.empty()
).
-
Method Summary
Modifier and Type Method Description static FormatValidator
forFormat(String formatName)
Static factory method forFormatValidator
implementations supporting theformatName
s mandated by the json schema spec.default String
formatName()
Provides the name of this format.Optional<String>
validate(String subject)
Implementation-specific validation ofsubject
.
-
-
-
Field Detail
-
NONE
static final FormatValidator NONE
No-operation implementation (never throws {always returnsOptional.empty()
).
-
-
Method Detail
-
forFormat
static FormatValidator forFormat(String formatName)
Static factory method forFormatValidator
implementations supporting theformatName
s mandated by the json schema spec.- date-time
- hostname
- uri
- ipv4
- ipv6
- Parameters:
formatName
- one of the 6 built-in formats.- Returns:
- a
FormatValidator
implementation handling theformatName
format.
-
validate
Optional<String> validate(String subject)
Implementation-specific validation ofsubject
. If a validation error occurs then implementations should return a programmer-friendly error message as a String wrapped in an Optional. If the validation succeeded thenan empty optional
should be returned.- Parameters:
subject
- the string to be validated- Returns:
- an
Optional
wrapping the error message if a validation error occured, otherwisean empty optional
.
-
formatName
default String formatName()
Provides the name of this format.Unless specified otherwise the
The default implementation of this method returnsSchemaLoader
will use this name to recognize string schemas using this format."unnamed-format"
. It is strongly recommended for implementations to give a more meaningful name by overriding this method.- Returns:
- the format name.
-
-