Class SchemaValidatorsConfig.Builder
- java.lang.Object
-
- com.networknt.schema.SchemaValidatorsConfig.Builder
-
- Enclosing class:
- SchemaValidatorsConfig
public static class SchemaValidatorsConfig.Builder extends Object
Builder forSchemaValidatorsConfig
.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
-
-
-
Method Detail
-
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
public SchemaValidatorsConfig.Builder 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 SchemaValidatorsConfig.Builder 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 SchemaValidatorsConfig.Builder executionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)
Sets the execution context customizer that is run before each run.- Parameters:
executionContextCustomizer
- the customizer- Returns:
- the builder
-
failFast
public SchemaValidatorsConfig.Builder 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 SchemaValidatorsConfig.Builder formatAssertionsEnabled(Boolean formatAssertionsEnabled)
Sets if format assertions are enabled. If format assertions are not enabled the format keyword will behave like a 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
public SchemaValidatorsConfig.Builder nullableKeywordEnabled(boolean 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
public SchemaValidatorsConfig.Builder javaSemantics(boolean javaSemantics)
-
keywordWalkListeners
public SchemaValidatorsConfig.Builder keywordWalkListeners(Map<String,List<JsonSchemaWalkListener>> keywordWalkListeners)
-
locale
public SchemaValidatorsConfig.Builder locale(Locale 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
public SchemaValidatorsConfig.Builder losslessNarrowing(boolean losslessNarrowing)
-
messageSource
public SchemaValidatorsConfig.Builder messageSource(MessageSource 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
public SchemaValidatorsConfig.Builder 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
-
preloadJsonSchema
public SchemaValidatorsConfig.Builder preloadJsonSchema(boolean 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
public SchemaValidatorsConfig.Builder readOnly(Boolean 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:
JDKRegularExpressionFactory
,ECMAScriptRegularExpressionFactory
-
schemaIdValidator
public SchemaValidatorsConfig.Builder schemaIdValidator(JsonSchemaIdValidator schemaIdValidator)
Sets the schema id validator to use.Defaults to
JsonSchemaIdValidator.DEFAULT
.- Parameters:
schemaIdValidator
- the builder- Returns:
- the builder
-
strict
public SchemaValidatorsConfig.Builder strict(Map<String,Boolean> strict)
-
typeLoose
public SchemaValidatorsConfig.Builder typeLoose(boolean typeLoose)
-
writeOnly
public SchemaValidatorsConfig.Builder writeOnly(Boolean writeOnly)
-
build
public SchemaValidatorsConfig build()
-
strict
public SchemaValidatorsConfig.Builder strict(String keyword, boolean 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
public SchemaValidatorsConfig.Builder itemWalkListener(JsonSchemaWalkListener itemWalkListener)
-
itemWalkListeners
public SchemaValidatorsConfig.Builder itemWalkListeners(Consumer<List<JsonSchemaWalkListener>> itemWalkListeners)
-
-