Class SchemaValidatorsConfig.ImmutableSchemaValidatorsConfig
- java.lang.Object
-
- com.networknt.schema.SchemaValidatorsConfig
-
- com.networknt.schema.SchemaValidatorsConfig.ImmutableSchemaValidatorsConfig
-
- Enclosing class:
- SchemaValidatorsConfig
public static class SchemaValidatorsConfig.ImmutableSchemaValidatorsConfig extends SchemaValidatorsConfig
SchemaValidatorsConfig
that throws on mutators or deprecated methods.The
SchemaValidatorsConfig
will be made immutable in a future breaking release.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.networknt.schema.SchemaValidatorsConfig
SchemaValidatorsConfig.Builder, SchemaValidatorsConfig.ImmutableSchemaValidatorsConfig
-
-
Field Summary
-
Fields inherited from class com.networknt.schema.SchemaValidatorsConfig
ALL_KEYWORD_WALK_LISTENER_KEY, DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH
-
-
Constructor Summary
Constructors Constructor Description ImmutableSchemaValidatorsConfig(ApplyDefaultsStrategy applyDefaultsStrategy, boolean cacheRefs, String errorMessageKeyword, ExecutionContextCustomizer executionContextCustomizer, boolean failFast, Boolean formatAssertionsEnabled, boolean handleNullableField, List<JsonSchemaWalkListener> itemWalkListeners, boolean javaSemantics, Map<String,List<JsonSchemaWalkListener>> keywordWalkListenersMap, Locale locale, boolean losslessNarrowing, MessageSource messageSource, boolean openAPI3StyleDiscriminators, PathType pathType, boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, List<JsonSchemaWalkListener> propertyWalkListeners, Boolean readOnly, RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, Map<String,Boolean> strictness, boolean typeLoose, Boolean writeOnly)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItemWalkListener(JsonSchemaWalkListener itemWalkListener)
void
addItemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners)
void
addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)
void
addKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener)
void
addKeywordWalkListeners(String keyword, List<JsonSchemaWalkListener> keywordWalkListeners)
void
addKeywordWalkListeners(List<JsonSchemaWalkListener> keywordWalkListeners)
void
addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)
void
addPropertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners)
SchemaValidatorsConfig
disableUnevaluatedAnalysis()
SchemaValidatorsConfig
disableUnevaluatedItems()
SchemaValidatorsConfig
disableUnevaluatedProperties()
SchemaValidatorsConfig
enableUnevaluatedAnalysis()
SchemaValidatorsConfig
enableUnevaluatedItems()
SchemaValidatorsConfig
enableUnevaluatedProperties()
void
setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)
void
setCacheRefs(boolean cacheRefs)
Sets if schemas loaded from refs will be cached and reused for subsequent runs.void
setCustomMessageSupported(boolean customMessageSupported)
Sets whether custom error messages in the schema are used.void
setEcma262Validator(boolean ecma262Validator)
Sets whether to use a ECMA-262 compliant regular expression validator.void
setExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)
void
setFailFast(boolean failFast)
When enabled,JsonValidator.validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)
doesn't return anySet
<ValidationMessage
>, instead aJsonSchemaException
is thrown as soon as a validation errors is discovered.void
setFormatAssertionsEnabled(Boolean formatAssertionsEnabled)
Sets the format assertion enabled flag.void
setHandleNullableField(boolean handleNullableField)
void
setJavaSemantics(boolean javaSemantics)
void
setLoadCollectors(boolean loadCollectors)
Sets if collectors are to be loaded.void
setLocale(Locale locale)
Set the locale to consider when generating localised messages.void
setLosslessNarrowing(boolean losslessNarrowing)
void
setMessageSource(MessageSource messageSource)
Set the message source to use for generating localised messages.void
setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)
When enabled, the validation ofanyOf
andallOf
in polymorphism will respect OpenAPI 3 style discriminators as described in the OpenAPI 3.0.3 spec.void
setPathType(PathType pathType)
Set the approach used to generate paths in messages, logs and errors (default is PathType.LEGACY).void
setPreloadJsonSchema(boolean preloadJsonSchema)
Sets if the schema should be preloaded.void
setPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth)
Sets the max depth of the evaluation path to preload when preloading refs.void
setReadOnly(boolean readOnly)
void
setRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory)
Sets the regular expression factory.void
setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator)
Sets the schema id validator to validate $id.void
setStrict(String keyword, boolean strict)
Alters the strictness of validations for a specific keyword.void
setTypeLoose(boolean typeLoose)
void
setWriteOnly(boolean writeOnly)
-
Methods inherited from class com.networknt.schema.SchemaValidatorsConfig
builder, builder, doLoadCollectors, getApplyDefaultsStrategy, getArrayItemWalkListeners, getErrorMessageKeyword, getExecutionContextCustomizer, getFormatAssertionsEnabled, getKeywordWalkListenersMap, getLocale, getMessageSource, getPathType, getPreloadJsonSchemaRefMaxNestingDepth, getPropertyWalkListeners, getRegularExpressionFactory, getSchemaIdValidator, isCacheRefs, isCustomMessageSupported, isDiscriminatorKeywordEnabled, isEcma262Validator, isFailFast, isHandleNullableField, isJavaSemantics, isLosslessNarrowing, isNullableKeywordEnabled, isOpenAPI3StyleDiscriminators, isPreloadJsonSchema, isReadOnly, isStrict, isStrict, isTypeLoose, isUnevaluatedItemsAnalysisDisabled, isUnevaluatedItemsAnalysisEnabled, isUnevaluatedPropertiesAnalysisDisabled, isUnevaluatedPropertiesAnalysisEnabled, isWriteMode, isWriteOnly
-
-
-
-
Constructor Detail
-
ImmutableSchemaValidatorsConfig
public ImmutableSchemaValidatorsConfig(ApplyDefaultsStrategy applyDefaultsStrategy, boolean cacheRefs, String errorMessageKeyword, ExecutionContextCustomizer executionContextCustomizer, boolean failFast, Boolean formatAssertionsEnabled, boolean handleNullableField, List<JsonSchemaWalkListener> itemWalkListeners, boolean javaSemantics, Map<String,List<JsonSchemaWalkListener>> keywordWalkListenersMap, Locale locale, boolean losslessNarrowing, MessageSource messageSource, boolean openAPI3StyleDiscriminators, PathType pathType, boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth, List<JsonSchemaWalkListener> propertyWalkListeners, Boolean readOnly, RegularExpressionFactory regularExpressionFactory, JsonSchemaIdValidator schemaIdValidator, Map<String,Boolean> strictness, boolean typeLoose, Boolean writeOnly)
-
-
Method Detail
-
addItemWalkListener
public void addItemWalkListener(JsonSchemaWalkListener itemWalkListener)
- Overrides:
addItemWalkListener
in classSchemaValidatorsConfig
-
addItemWalkListeners
public void addItemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners)
- Overrides:
addItemWalkListeners
in classSchemaValidatorsConfig
-
addKeywordWalkListener
public void addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)
- Overrides:
addKeywordWalkListener
in classSchemaValidatorsConfig
-
addKeywordWalkListener
public void addKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener)
- Overrides:
addKeywordWalkListener
in classSchemaValidatorsConfig
-
addKeywordWalkListeners
public void addKeywordWalkListeners(List<JsonSchemaWalkListener> keywordWalkListeners)
- Overrides:
addKeywordWalkListeners
in classSchemaValidatorsConfig
-
addKeywordWalkListeners
public void addKeywordWalkListeners(String keyword, List<JsonSchemaWalkListener> keywordWalkListeners)
- Overrides:
addKeywordWalkListeners
in classSchemaValidatorsConfig
-
addPropertyWalkListener
public void addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)
- Overrides:
addPropertyWalkListener
in classSchemaValidatorsConfig
-
addPropertyWalkListeners
public void addPropertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners)
- Overrides:
addPropertyWalkListeners
in classSchemaValidatorsConfig
-
setApplyDefaultsStrategy
public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)
- Overrides:
setApplyDefaultsStrategy
in classSchemaValidatorsConfig
-
setCacheRefs
public void setCacheRefs(boolean cacheRefs)
Description copied from class:SchemaValidatorsConfig
Sets if schemas loaded from refs will be cached and reused for subsequent runs.Note that setting this to false will affect performance as refs will need to be repeatedly resolved for each evaluation run. It may be needed to be set to false if there are multiple nested applicators like anyOf, oneOf and allOf as that will consume a lot of memory to cache all the permutations.
- Overrides:
setCacheRefs
in classSchemaValidatorsConfig
- Parameters:
cacheRefs
- true to cache
-
setCustomMessageSupported
public void setCustomMessageSupported(boolean customMessageSupported)
Description copied from class:SchemaValidatorsConfig
Sets whether custom error messages in the schema are used.This is deprecated in favor of setting the error message keyword to use.
- Overrides:
setCustomMessageSupported
in classSchemaValidatorsConfig
- Parameters:
customMessageSupported
- true to use message as the error message keyword
-
setEcma262Validator
public void setEcma262Validator(boolean ecma262Validator)
Description copied from class:SchemaValidatorsConfig
Sets whether to use a ECMA-262 compliant regular expression validator.This defaults to the false and setting true require inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.
- Overrides:
setEcma262Validator
in classSchemaValidatorsConfig
- Parameters:
ecma262Validator
- true if ECMA-262 compliant
-
setExecutionContextCustomizer
public void setExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)
- Overrides:
setExecutionContextCustomizer
in classSchemaValidatorsConfig
-
setFailFast
public void setFailFast(boolean failFast)
Description copied from class:SchemaValidatorsConfig
When enabled,JsonValidator.validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)
doesn't return anySet
<ValidationMessage
>, instead aJsonSchemaException
is thrown as soon as a validation errors is discovered.- Overrides:
setFailFast
in classSchemaValidatorsConfig
- Parameters:
failFast
- boolean
-
setFormatAssertionsEnabled
public void setFormatAssertionsEnabled(Boolean formatAssertionsEnabled)
Description copied from class:SchemaValidatorsConfig
Sets the format assertion enabled flag.This is deprecated. Either set this using the builder SchemaValidatorsConfig.builder().formatAssertionsEnabled(true).build() or this should be set via executionContext.getExecutionConfig().setFormatAssertionsEnabled(true).
- Overrides:
setFormatAssertionsEnabled
in classSchemaValidatorsConfig
- Parameters:
formatAssertionsEnabled
- the format assertions enabled flag
-
setHandleNullableField
public void setHandleNullableField(boolean handleNullableField)
- Overrides:
setHandleNullableField
in classSchemaValidatorsConfig
-
setJavaSemantics
public void setJavaSemantics(boolean javaSemantics)
- Overrides:
setJavaSemantics
in classSchemaValidatorsConfig
-
setLocale
public void setLocale(Locale locale)
Description copied from class:SchemaValidatorsConfig
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)
.This is deprecated. Either set this using the builder SchemaValidatorsConfig.builder().locale(locale).build() or this should be set via executionContext.getExecutionConfig().setLocale(locale).
- Overrides:
setLocale
in classSchemaValidatorsConfig
- Parameters:
locale
- The locale.
-
setLosslessNarrowing
public void setLosslessNarrowing(boolean losslessNarrowing)
- Overrides:
setLosslessNarrowing
in classSchemaValidatorsConfig
-
setMessageSource
public void setMessageSource(MessageSource messageSource)
Description copied from class:SchemaValidatorsConfig
Set the message source to use for generating localised messages.- Overrides:
setMessageSource
in classSchemaValidatorsConfig
- Parameters:
messageSource
- the message source
-
setOpenAPI3StyleDiscriminators
public void setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)
Description copied from class:SchemaValidatorsConfig
When enabled, the validation ofanyOf
andallOf
in polymorphism will respect OpenAPI 3 style discriminators as described in the OpenAPI 3.0.3 spec. The presence of a discriminator configuration on the schema will lead to the following changes in the behavior:- for
oneOf
the spec is unfortunately very vague. WhetheroneOf
semantics should be affected by discriminators or not is not even 100% clear within the members of the OAS steering committee. ThereforeoneOf
at the moment ignores discriminators - for
anyOf
the validation will choose one of the candidate schemas for validation based on the discriminator property value and will pass validation when this specific schema passes. This is in particular useful when the payload could match multiple candidates in theanyOf
list and could lead to ambiguity. Example: type B has all mandatory properties of A and adds more mandatory ones. Whether the payload is an A or B is determined via the discriminator property name. A payload indicating it is an instance of B then requires passing the validation of B and passing the validation of A would not be sufficient anymore. - for
allOf
use cases with discriminators defined on the copied-in parent type, it is possible to automatically validate against a subtype. Example: some schema specifies that there is a field of type A. A carries a discriminator field and B inherits from A. Then B is automatically a candidate for validation as well and will be chosen in case the discriminator property matches
- Overrides:
setOpenAPI3StyleDiscriminators
in classSchemaValidatorsConfig
- Parameters:
openAPI3StyleDiscriminators
- whether or not discriminators should be used. Defaults tofalse
- for
-
setPathType
public void setPathType(PathType pathType)
Description copied from class:SchemaValidatorsConfig
Set the approach used to generate paths in messages, logs and errors (default is PathType.LEGACY).- Overrides:
setPathType
in classSchemaValidatorsConfig
- Parameters:
pathType
- The path generation approach.
-
setPreloadJsonSchema
public void setPreloadJsonSchema(boolean preloadJsonSchema)
Description copied from class:SchemaValidatorsConfig
Sets if the schema should be preloaded.- Overrides:
setPreloadJsonSchema
in classSchemaValidatorsConfig
- Parameters:
preloadJsonSchema
- true to preload
-
setPreloadJsonSchemaRefMaxNestingDepth
public void setPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth)
Description copied from class:SchemaValidatorsConfig
Sets the max depth of the evaluation path to preload when preloading refs.- Overrides:
setPreloadJsonSchemaRefMaxNestingDepth
in classSchemaValidatorsConfig
- Parameters:
preloadJsonSchemaRefMaxNestingDepth
- the max depth to preload
-
setReadOnly
public void setReadOnly(boolean readOnly)
- Overrides:
setReadOnly
in classSchemaValidatorsConfig
-
setRegularExpressionFactory
public void setRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory)
Description copied from class:SchemaValidatorsConfig
Sets the regular expression factory.This defaults to the JDKRegularExpressionFactory and the implementations require inclusion of optional org.jruby.joni:joni or org.graalvm.js:js dependencies.
- Overrides:
setRegularExpressionFactory
in classSchemaValidatorsConfig
- Parameters:
regularExpressionFactory
- the factory- See Also:
JDKRegularExpressionFactory
,ECMAScriptRegularExpressionFactory
-
setSchemaIdValidator
public void setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator)
Description copied from class:SchemaValidatorsConfig
Sets the schema id validator to validate $id.- Overrides:
setSchemaIdValidator
in classSchemaValidatorsConfig
- Parameters:
schemaIdValidator
- the validator
-
setStrict
public void setStrict(String keyword, boolean strict)
Description copied from class:SchemaValidatorsConfig
Alters the strictness of validations for a specific keyword. When set to true, instructs the keyword's validators to perform strict validation. Otherwise, a validator may perform a more permissive check.- Overrides:
setStrict
in classSchemaValidatorsConfig
- Parameters:
keyword
- The keyword to adjust (not null)strict
- Whether to perform strict validations
-
setTypeLoose
public void setTypeLoose(boolean typeLoose)
- Overrides:
setTypeLoose
in classSchemaValidatorsConfig
-
setWriteOnly
public void setWriteOnly(boolean writeOnly)
- Overrides:
setWriteOnly
in classSchemaValidatorsConfig
-
setLoadCollectors
public void setLoadCollectors(boolean loadCollectors)
Description copied from class:SchemaValidatorsConfig
Sets if collectors are to be loaded.This is deprecated in favor of the caller calling
CollectorContext.loadCollectors()
manually.- Overrides:
setLoadCollectors
in classSchemaValidatorsConfig
- Parameters:
loadCollectors
- to load collectors
-
disableUnevaluatedAnalysis
public SchemaValidatorsConfig disableUnevaluatedAnalysis()
- Overrides:
disableUnevaluatedAnalysis
in classSchemaValidatorsConfig
-
disableUnevaluatedItems
public SchemaValidatorsConfig disableUnevaluatedItems()
- Overrides:
disableUnevaluatedItems
in classSchemaValidatorsConfig
-
disableUnevaluatedProperties
public SchemaValidatorsConfig disableUnevaluatedProperties()
- Overrides:
disableUnevaluatedProperties
in classSchemaValidatorsConfig
-
enableUnevaluatedAnalysis
public SchemaValidatorsConfig enableUnevaluatedAnalysis()
- Overrides:
enableUnevaluatedAnalysis
in classSchemaValidatorsConfig
-
enableUnevaluatedItems
public SchemaValidatorsConfig enableUnevaluatedItems()
- Overrides:
enableUnevaluatedItems
in classSchemaValidatorsConfig
-
enableUnevaluatedProperties
public SchemaValidatorsConfig enableUnevaluatedProperties()
- Overrides:
enableUnevaluatedProperties
in classSchemaValidatorsConfig
-
-