Class SchemaValidatorsConfig.Builder
- Enclosing class:
SchemaValidatorsConfig
SchemaValidatorsConfig
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyDefaultsStrategy
(ApplyDefaultsStrategy applyDefaultsStrategy) Sets the strategy the walker uses to sets nodes to the default value.build()
cacheRefs
(boolean cacheRefs) Sets if schemas loaded from refs will be cached and reused for subsequent runs.discriminatorKeywordEnabled
(boolean discriminatorKeywordEnabled) Sets if the discriminator keyword is enabled.errorMessageKeyword
(String errorMessageKeyword) Sets the error message keyword for setting custom messages in the schema.executionContextCustomizer
(ExecutionContextCustomizer executionContextCustomizer) Sets the execution context customizer that is run before each run.failFast
(boolean failFast) Sets if the validation should immediately return once a validation error has occurred.formatAssertionsEnabled
(Boolean formatAssertionsEnabled) Sets if format assertions are enabled.itemWalkListener
(JsonSchemaWalkListener itemWalkListener) itemWalkListeners
(Consumer<List<JsonSchemaWalkListener>> itemWalkListeners) itemWalkListeners
(List<JsonSchemaWalkListener> itemWalkListeners) javaSemantics
(boolean javaSemantics) keywordWalkListener
(JsonSchemaWalkListener keywordWalkListener) keywordWalkListener
(String keyword, JsonSchemaWalkListener keywordWalkListener) keywordWalkListeners
(Consumer<Map<String, List<JsonSchemaWalkListener>>> keywordWalkListeners) keywordWalkListeners
(Map<String, List<JsonSchemaWalkListener>> keywordWalkListeners) Set the locale to consider when generating localised messages.losslessNarrowing
(boolean losslessNarrowing) messageSource
(MessageSource messageSource) Sets the message source to use for generating localised messages.nullableKeywordEnabled
(boolean nullableKeywordEnabled) Sets if the nullable keyword is enabled.Sets the path type to use when reporting the instance location of errors.preloadJsonSchema
(boolean preloadJsonSchema) Sets if the schema should be preloaded.preloadJsonSchemaRefMaxNestingDepth
(int preloadJsonSchemaRefMaxNestingDepth) Sets the max depth of the evaluation path to preload when preloading refs.propertyWalkListener
(JsonSchemaWalkListener propertyWalkListener) propertyWalkListeners
(Consumer<List<JsonSchemaWalkListener>> propertyWalkListeners) propertyWalkListeners
(List<JsonSchemaWalkListener> propertyWalkListeners) regularExpressionFactory
(RegularExpressionFactory regularExpressionFactory) Sets the regular expression factory.schemaIdValidator
(JsonSchemaIdValidator schemaIdValidator) Sets the schema id validator to use.typeLoose
(boolean typeLoose)
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
applyDefaultsStrategy
public SchemaValidatorsConfig.Builder applyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy) Sets the strategy the walker uses to sets nodes to the default value.Defaults to
ApplyDefaultsStrategy.EMPTY_APPLY_DEFAULTS_STRATEGY
.- Parameters:
applyDefaultsStrategy
- the strategy- Returns:
- the builder
-
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
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 SchemaValidatorsConfig.Builder executionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer) Sets the execution context customizer that is run before each run.- Parameters:
executionContextCustomizer
- the customizer- Returns:
- the builder
-
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
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
-
nullableKeywordEnabled
Sets if the nullable keyword is enabled.- Parameters:
nullableKeywordEnabled
- true to enable- Returns:
- the builder
-
itemWalkListeners
public SchemaValidatorsConfig.Builder itemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners) -
javaSemantics
-
keywordWalkListeners
public SchemaValidatorsConfig.Builder keywordWalkListeners(Map<String, List<JsonSchemaWalkListener>> keywordWalkListeners) -
locale
Set the locale to consider when generating localised messages.Note that this locale is set on a schema basis. To configure the schema on a per execution basis use
ExecutionConfig.setLocale(Locale)
.Defaults to use
Locale.getDefault()
.- Parameters:
locale
- The locale.- Returns:
- the builder
-
losslessNarrowing
-
messageSource
Sets the message source to use for generating localised messages.- Parameters:
messageSource
- the message source- Returns:
- the builder
-
discriminatorKeywordEnabled
public SchemaValidatorsConfig.Builder discriminatorKeywordEnabled(boolean discriminatorKeywordEnabled) Sets if the discriminator keyword is enabled.Defaults to false.
- Parameters:
discriminatorKeywordEnabled
- true to enable- Returns:
- the builder
-
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
-
preloadJsonSchema
Sets if the schema should be preloaded.Defaults to true.
- Parameters:
preloadJsonSchema
- true to preload- Returns:
- the builder
-
preloadJsonSchemaRefMaxNestingDepth
public SchemaValidatorsConfig.Builder preloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth) Sets the max depth of the evaluation path to preload when preloading refs.Defaults to 40.
- Parameters:
preloadJsonSchemaRefMaxNestingDepth
- to preload- Returns:
- the builder
-
propertyWalkListeners
public SchemaValidatorsConfig.Builder propertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners) -
readOnly
-
regularExpressionFactory
public SchemaValidatorsConfig.Builder regularExpressionFactory(RegularExpressionFactory regularExpressionFactory) Sets the regular expression factory.Defaults to the
JDKRegularExpressionFactory
The
ECMAScriptRegularExpressionFactory
requires the inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.- Parameters:
regularExpressionFactory
- the factory- Returns:
- the builder
- See Also:
-
schemaIdValidator
Sets the schema id validator to use.Defaults to
JsonSchemaIdValidator.DEFAULT
.- Parameters:
schemaIdValidator
- the builder- Returns:
- the builder
-
strict
-
typeLoose
-
writeOnly
-
build
-
strict
-
keywordWalkListener
public SchemaValidatorsConfig.Builder keywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener) -
keywordWalkListener
public SchemaValidatorsConfig.Builder keywordWalkListener(JsonSchemaWalkListener keywordWalkListener) -
keywordWalkListeners
public SchemaValidatorsConfig.Builder keywordWalkListeners(Consumer<Map<String, List<JsonSchemaWalkListener>>> keywordWalkListeners) -
propertyWalkListener
public SchemaValidatorsConfig.Builder propertyWalkListener(JsonSchemaWalkListener propertyWalkListener) -
propertyWalkListeners
public SchemaValidatorsConfig.Builder propertyWalkListeners(Consumer<List<JsonSchemaWalkListener>> propertyWalkListeners) -
itemWalkListener
-
itemWalkListeners
public SchemaValidatorsConfig.Builder itemWalkListeners(Consumer<List<JsonSchemaWalkListener>> itemWalkListeners)
-