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
SchemaValidatorsConfigthat throws on mutators or deprecated methods.The
SchemaValidatorsConfigwill 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 voidaddItemWalkListener(JsonSchemaWalkListener itemWalkListener)voidaddItemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners)voidaddKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)voidaddKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener)voidaddKeywordWalkListeners(String keyword, List<JsonSchemaWalkListener> keywordWalkListeners)voidaddKeywordWalkListeners(List<JsonSchemaWalkListener> keywordWalkListeners)voidaddPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)voidaddPropertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners)SchemaValidatorsConfigdisableUnevaluatedAnalysis()SchemaValidatorsConfigdisableUnevaluatedItems()SchemaValidatorsConfigdisableUnevaluatedProperties()SchemaValidatorsConfigenableUnevaluatedAnalysis()SchemaValidatorsConfigenableUnevaluatedItems()SchemaValidatorsConfigenableUnevaluatedProperties()voidsetApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)voidsetCacheRefs(boolean cacheRefs)Sets if schemas loaded from refs will be cached and reused for subsequent runs.voidsetCustomMessageSupported(boolean customMessageSupported)Sets whether custom error messages in the schema are used.voidsetEcma262Validator(boolean ecma262Validator)Sets whether to use a ECMA-262 compliant regular expression validator.voidsetExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)voidsetFailFast(boolean failFast)When enabled,JsonValidator.validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)doesn't return anySet<ValidationMessage>, instead aJsonSchemaExceptionis thrown as soon as a validation errors is discovered.voidsetFormatAssertionsEnabled(Boolean formatAssertionsEnabled)Sets the format assertion enabled flag.voidsetHandleNullableField(boolean handleNullableField)voidsetJavaSemantics(boolean javaSemantics)voidsetLoadCollectors(boolean loadCollectors)Sets if collectors are to be loaded.voidsetLocale(Locale locale)Set the locale to consider when generating localised messages.voidsetLosslessNarrowing(boolean losslessNarrowing)voidsetMessageSource(MessageSource messageSource)Set the message source to use for generating localised messages.voidsetOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)When enabled, the validation ofanyOfandallOfin polymorphism will respect OpenAPI 3 style discriminators as described in the OpenAPI 3.0.3 spec.voidsetPathType(PathType pathType)Set the approach used to generate paths in messages, logs and errors (default is PathType.LEGACY).voidsetPreloadJsonSchema(boolean preloadJsonSchema)Sets if the schema should be preloaded.voidsetPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth)Sets the max depth of the evaluation path to preload when preloading refs.voidsetReadOnly(boolean readOnly)voidsetRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory)Sets the regular expression factory.voidsetSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator)Sets the schema id validator to validate $id.voidsetStrict(String keyword, boolean strict)Alters the strictness of validations for a specific keyword.voidsetTypeLoose(boolean typeLoose)voidsetWriteOnly(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:
addItemWalkListenerin classSchemaValidatorsConfig
-
addItemWalkListeners
public void addItemWalkListeners(List<JsonSchemaWalkListener> itemWalkListeners)
- Overrides:
addItemWalkListenersin classSchemaValidatorsConfig
-
addKeywordWalkListener
public void addKeywordWalkListener(JsonSchemaWalkListener keywordWalkListener)
- Overrides:
addKeywordWalkListenerin classSchemaValidatorsConfig
-
addKeywordWalkListener
public void addKeywordWalkListener(String keyword, JsonSchemaWalkListener keywordWalkListener)
- Overrides:
addKeywordWalkListenerin classSchemaValidatorsConfig
-
addKeywordWalkListeners
public void addKeywordWalkListeners(List<JsonSchemaWalkListener> keywordWalkListeners)
- Overrides:
addKeywordWalkListenersin classSchemaValidatorsConfig
-
addKeywordWalkListeners
public void addKeywordWalkListeners(String keyword, List<JsonSchemaWalkListener> keywordWalkListeners)
- Overrides:
addKeywordWalkListenersin classSchemaValidatorsConfig
-
addPropertyWalkListener
public void addPropertyWalkListener(JsonSchemaWalkListener propertyWalkListener)
- Overrides:
addPropertyWalkListenerin classSchemaValidatorsConfig
-
addPropertyWalkListeners
public void addPropertyWalkListeners(List<JsonSchemaWalkListener> propertyWalkListeners)
- Overrides:
addPropertyWalkListenersin classSchemaValidatorsConfig
-
setApplyDefaultsStrategy
public void setApplyDefaultsStrategy(ApplyDefaultsStrategy applyDefaultsStrategy)
- Overrides:
setApplyDefaultsStrategyin classSchemaValidatorsConfig
-
setCacheRefs
public void setCacheRefs(boolean cacheRefs)
Description copied from class:SchemaValidatorsConfigSets 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:
setCacheRefsin classSchemaValidatorsConfig- Parameters:
cacheRefs- true to cache
-
setCustomMessageSupported
public void setCustomMessageSupported(boolean customMessageSupported)
Description copied from class:SchemaValidatorsConfigSets whether custom error messages in the schema are used.This is deprecated in favor of setting the error message keyword to use.
- Overrides:
setCustomMessageSupportedin classSchemaValidatorsConfig- Parameters:
customMessageSupported- true to use message as the error message keyword
-
setEcma262Validator
public void setEcma262Validator(boolean ecma262Validator)
Description copied from class:SchemaValidatorsConfigSets 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:
setEcma262Validatorin classSchemaValidatorsConfig- Parameters:
ecma262Validator- true if ECMA-262 compliant
-
setExecutionContextCustomizer
public void setExecutionContextCustomizer(ExecutionContextCustomizer executionContextCustomizer)
- Overrides:
setExecutionContextCustomizerin classSchemaValidatorsConfig
-
setFailFast
public void setFailFast(boolean failFast)
Description copied from class:SchemaValidatorsConfigWhen enabled,JsonValidator.validate(ExecutionContext, JsonNode, JsonNode, JsonNodePath)doesn't return anySet<ValidationMessage>, instead aJsonSchemaExceptionis thrown as soon as a validation errors is discovered.- Overrides:
setFailFastin classSchemaValidatorsConfig- Parameters:
failFast- boolean
-
setFormatAssertionsEnabled
public void setFormatAssertionsEnabled(Boolean formatAssertionsEnabled)
Description copied from class:SchemaValidatorsConfigSets 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:
setFormatAssertionsEnabledin classSchemaValidatorsConfig- Parameters:
formatAssertionsEnabled- the format assertions enabled flag
-
setHandleNullableField
public void setHandleNullableField(boolean handleNullableField)
- Overrides:
setHandleNullableFieldin classSchemaValidatorsConfig
-
setJavaSemantics
public void setJavaSemantics(boolean javaSemantics)
- Overrides:
setJavaSemanticsin classSchemaValidatorsConfig
-
setLocale
public void setLocale(Locale locale)
Description copied from class:SchemaValidatorsConfigSet 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:
setLocalein classSchemaValidatorsConfig- Parameters:
locale- The locale.
-
setLosslessNarrowing
public void setLosslessNarrowing(boolean losslessNarrowing)
- Overrides:
setLosslessNarrowingin classSchemaValidatorsConfig
-
setMessageSource
public void setMessageSource(MessageSource messageSource)
Description copied from class:SchemaValidatorsConfigSet the message source to use for generating localised messages.- Overrides:
setMessageSourcein classSchemaValidatorsConfig- Parameters:
messageSource- the message source
-
setOpenAPI3StyleDiscriminators
public void setOpenAPI3StyleDiscriminators(boolean openAPI3StyleDiscriminators)
Description copied from class:SchemaValidatorsConfigWhen enabled, the validation ofanyOfandallOfin 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
oneOfthe spec is unfortunately very vague. WhetheroneOfsemantics should be affected by discriminators or not is not even 100% clear within the members of the OAS steering committee. ThereforeoneOfat the moment ignores discriminators - for
anyOfthe 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 theanyOflist 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
allOfuse 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:
setOpenAPI3StyleDiscriminatorsin classSchemaValidatorsConfig- Parameters:
openAPI3StyleDiscriminators- whether or not discriminators should be used. Defaults tofalse
- for
-
setPathType
public void setPathType(PathType pathType)
Description copied from class:SchemaValidatorsConfigSet the approach used to generate paths in messages, logs and errors (default is PathType.LEGACY).- Overrides:
setPathTypein classSchemaValidatorsConfig- Parameters:
pathType- The path generation approach.
-
setPreloadJsonSchema
public void setPreloadJsonSchema(boolean preloadJsonSchema)
Description copied from class:SchemaValidatorsConfigSets if the schema should be preloaded.- Overrides:
setPreloadJsonSchemain classSchemaValidatorsConfig- Parameters:
preloadJsonSchema- true to preload
-
setPreloadJsonSchemaRefMaxNestingDepth
public void setPreloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth)
Description copied from class:SchemaValidatorsConfigSets the max depth of the evaluation path to preload when preloading refs.- Overrides:
setPreloadJsonSchemaRefMaxNestingDepthin classSchemaValidatorsConfig- Parameters:
preloadJsonSchemaRefMaxNestingDepth- the max depth to preload
-
setReadOnly
public void setReadOnly(boolean readOnly)
- Overrides:
setReadOnlyin classSchemaValidatorsConfig
-
setRegularExpressionFactory
public void setRegularExpressionFactory(RegularExpressionFactory regularExpressionFactory)
Description copied from class:SchemaValidatorsConfigSets 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:
setRegularExpressionFactoryin classSchemaValidatorsConfig- Parameters:
regularExpressionFactory- the factory- See Also:
JDKRegularExpressionFactory,ECMAScriptRegularExpressionFactory
-
setSchemaIdValidator
public void setSchemaIdValidator(JsonSchemaIdValidator schemaIdValidator)
Description copied from class:SchemaValidatorsConfigSets the schema id validator to validate $id.- Overrides:
setSchemaIdValidatorin classSchemaValidatorsConfig- Parameters:
schemaIdValidator- the validator
-
setStrict
public void setStrict(String keyword, boolean strict)
Description copied from class:SchemaValidatorsConfigAlters 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:
setStrictin classSchemaValidatorsConfig- Parameters:
keyword- The keyword to adjust (not null)strict- Whether to perform strict validations
-
setTypeLoose
public void setTypeLoose(boolean typeLoose)
- Overrides:
setTypeLoosein classSchemaValidatorsConfig
-
setWriteOnly
public void setWriteOnly(boolean writeOnly)
- Overrides:
setWriteOnlyin classSchemaValidatorsConfig
-
setLoadCollectors
public void setLoadCollectors(boolean loadCollectors)
Description copied from class:SchemaValidatorsConfigSets if collectors are to be loaded.This is deprecated in favor of the caller calling
CollectorContext.loadCollectors()manually.- Overrides:
setLoadCollectorsin classSchemaValidatorsConfig- Parameters:
loadCollectors- to load collectors
-
disableUnevaluatedAnalysis
public SchemaValidatorsConfig disableUnevaluatedAnalysis()
- Overrides:
disableUnevaluatedAnalysisin classSchemaValidatorsConfig
-
disableUnevaluatedItems
public SchemaValidatorsConfig disableUnevaluatedItems()
- Overrides:
disableUnevaluatedItemsin classSchemaValidatorsConfig
-
disableUnevaluatedProperties
public SchemaValidatorsConfig disableUnevaluatedProperties()
- Overrides:
disableUnevaluatedPropertiesin classSchemaValidatorsConfig
-
enableUnevaluatedAnalysis
public SchemaValidatorsConfig enableUnevaluatedAnalysis()
- Overrides:
enableUnevaluatedAnalysisin classSchemaValidatorsConfig
-
enableUnevaluatedItems
public SchemaValidatorsConfig enableUnevaluatedItems()
- Overrides:
enableUnevaluatedItemsin classSchemaValidatorsConfig
-
enableUnevaluatedProperties
public SchemaValidatorsConfig enableUnevaluatedProperties()
- Overrides:
enableUnevaluatedPropertiesin classSchemaValidatorsConfig
-
-