Class SchemaRegistryConfig.BuilderSupport<T>
- java.lang.Object
-
- com.networknt.schema.SchemaRegistryConfig.BuilderSupport<T>
-
- Direct Known Subclasses:
SchemaRegistryConfig.Builder
- Enclosing class:
- SchemaRegistryConfig
public abstract static class SchemaRegistryConfig.BuilderSupport<T> extends Object
Builder forSchemaRegistryConfig.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancacheRefsprotected StringerrorMessageKeywordprotected ExecutionContextCustomizerexecutionContextCustomizerprotected booleanfailFastprotected BooleanformatAssertionsEnabledprotected Localelocaleprotected booleanlosslessNarrowingprotected MessageSourcemessageSourceprotected PathTypepathTypeprotected booleanpreloadSchemaprotected RegularExpressionFactoryregularExpressionFactoryprotected SchemaIdValidatorschemaIdValidatorprotected Map<String,Boolean>strictnessprotected booleantypeLoose
-
Constructor Summary
Constructors Constructor Description BuilderSupport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description SchemaRegistryConfigbuild()TcacheRefs(boolean cacheRefs)Sets if schemas loaded from refs will be cached and reused for subsequent runs.TerrorMessageKeyword(String errorMessageKeyword)Sets the error message keyword for setting custom messages in the schema.TexecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)Sets the execution context customizer that is run before each run.TfailFast(boolean failFast)Sets if the validation should immediately return once a validation error has occurred.TformatAssertionsEnabled(Boolean formatAssertionsEnabled)Sets if format assertions are enabled.Tlocale(Locale locale)Set the locale to consider when generating localized messages.TlosslessNarrowing(boolean losslessNarrowing)Sets whether lossless narrowing of other numeric types to integer is performed.TmessageSource(MessageSource messageSource)Sets the message source to use for generating localised messages.TpathType(PathType pathType)Sets the path type to use when reporting the instance location of errors.TpreloadSchema(boolean preloadSchema)Sets if the schema should be preloaded.TregularExpressionFactory(RegularExpressionFactory regularExpressionFactory)Sets the regular expression factory.TschemaIdValidator(SchemaIdValidator schemaIdValidator)Sets the schema id validator to use.protected abstract Tself()Tstrict(String keyword, boolean strict)Tstrict(Map<String,Boolean> strict)TtypeLoose(boolean typeLoose)
-
-
-
Field Detail
-
cacheRefs
protected boolean cacheRefs
-
errorMessageKeyword
protected String errorMessageKeyword
-
executionContextCustomizer
protected ExecutionContextCustomizer executionContextCustomizer
-
failFast
protected boolean failFast
-
formatAssertionsEnabled
protected Boolean formatAssertionsEnabled
-
locale
protected Locale locale
-
losslessNarrowing
protected boolean losslessNarrowing
-
messageSource
protected MessageSource messageSource
-
pathType
protected PathType pathType
-
preloadSchema
protected boolean preloadSchema
-
regularExpressionFactory
protected RegularExpressionFactory regularExpressionFactory
-
schemaIdValidator
protected SchemaIdValidator schemaIdValidator
-
typeLoose
protected boolean typeLoose
-
-
Method Detail
-
self
protected abstract T self()
-
cacheRefs
public T cacheRefs(boolean cacheRefs)
Sets if schemas loaded from refs will be cached and reused for subsequent runs.Defaults to true.
- Parameters:
cacheRefs- true to cache- Returns:
- the builder
-
errorMessageKeyword
public T errorMessageKeyword(String errorMessageKeyword)
Sets the error message keyword for setting custom messages in the schema.Defaults to null meaning custom messages are not enabled.
- Parameters:
errorMessageKeyword- to use for custom messages in the schema- Returns:
- the builder
-
executionContextCustomizer
public T executionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)
Sets the execution context customizer that is run before each run.- Parameters:
executionContextCustomizer- the customizer- Returns:
- the builder
-
failFast
public T failFast(boolean failFast)
Sets if the validation should immediately return once a validation error has occurred. This can improve performance if inputs are invalid but cannot return all error messages to the caller.Defaults to false.
- Parameters:
failFast- true to enable- Returns:
- the builder
-
formatAssertionsEnabled
public T formatAssertionsEnabled(Boolean formatAssertionsEnabled)
Sets if format assertions are enabled. If format assertions are not enabled the format keyword will behave like an annotation and not attempt to validate if the inputs are valid.Defaults to not enabling format assertions for Draft 2019-09 and above and enabling format assertions for Draft 7 and below.
- Parameters:
formatAssertionsEnabled- true to enable- Returns:
- the builder
-
locale
public T locale(Locale locale)
Set the locale to consider when generating localized messages.Note that this locale is set on a schema registry basis. To configure the schema on a per execution basis use
ExecutionConfig.BuilderSupport.locale(Locale).Defaults to use
Locale.getDefault().- Parameters:
locale- The locale.- Returns:
- the builder
-
losslessNarrowing
public T losslessNarrowing(boolean losslessNarrowing)
Sets whether lossless narrowing of other numeric types to integer is performed.Note that this likely only has a visible effect for dialects written before Draft 6.
Since Draft 6 for example 1.0 is treated as an integer even without this enabled.
- Parameters:
losslessNarrowing- true to enable- Returns:
- the builder
-
messageSource
public T messageSource(MessageSource messageSource)
Sets the message source to use for generating localised messages.- Parameters:
messageSource- the message source- Returns:
- the builder
-
pathType
public T pathType(PathType pathType)
Sets the path type to use when reporting the instance location of errors.Defaults to
PathType.JSON_POINTER.- Parameters:
pathType- the path type- Returns:
- the path type
-
preloadSchema
public T preloadSchema(boolean preloadSchema)
Sets if the schema should be preloaded.Defaults to true.
- Parameters:
preloadSchema- true to preload- Returns:
- the builder
-
regularExpressionFactory
public T regularExpressionFactory(RegularExpressionFactory regularExpressionFactory)
Sets the regular expression factory.Defaults to the
JDKRegularExpressionFactoryThe
ECMAScriptRegularExpressionFactoryrequires the inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.- Parameters:
regularExpressionFactory- the factory- Returns:
- the builder
- See Also:
JDKRegularExpressionFactory,ECMAScriptRegularExpressionFactory
-
schemaIdValidator
public T schemaIdValidator(SchemaIdValidator schemaIdValidator)
Sets the schema id validator to use.Defaults to
SchemaIdValidator.DEFAULT.- Parameters:
schemaIdValidator- the builder- Returns:
- the builder
-
typeLoose
public T typeLoose(boolean typeLoose)
-
build
public SchemaRegistryConfig build()
-
-