public interface BaseHibernateValidatorConfiguration<S extends BaseHibernateValidatorConfiguration<S>> extends Configuration<S>
Should not be used directly, prefer HibernateValidatorConfiguration
or
PredefinedScopeHibernateValidatorConfiguration
.
Modifier and Type | Field and Description |
---|---|
static String |
ALLOW_MULTIPLE_CASCADED_VALIDATION_ON_RESULT
Property corresponding to the
allowMultipleCascadedValidationOnReturnValues(boolean) method. |
static String |
ALLOW_PARALLEL_METHODS_DEFINE_PARAMETER_CONSTRAINTS
Property corresponding to the
allowParallelMethodsDefineParameterConstraints(boolean) method. |
static String |
ALLOW_PARAMETER_CONSTRAINT_OVERRIDE
Property corresponding to the
allowOverridingMethodAlterParameterConstraint(boolean) method. |
static String |
CONSTRAINT_EXPRESSION_LANGUAGE_FEATURE_LEVEL
Property for configuring the Expression Language feature level for constraints, allowing to define which
Expression Language features are available for message interpolation.
|
static String |
CONSTRAINT_MAPPING_CONTRIBUTOR
Deprecated.
planned for removal. Use hibernate.validator.constraint_mapping_contributors instead.
|
static String |
CONSTRAINT_MAPPING_CONTRIBUTORS
Property for configuring constraint mapping contributors, allowing to set up one or more constraint mappings for
the default validator factory.
|
static String |
CUSTOM_VIOLATION_EXPRESSION_LANGUAGE_FEATURE_LEVEL
Property for configuring the Expression Language feature level for custom violations, allowing to define which
Expression Language features are available for message interpolation.
|
static String |
ENABLE_TRAVERSABLE_RESOLVER_RESULT_CACHE
Property corresponding to the
enableTraversableResolverResultCache(boolean) . |
static String |
FAIL_FAST
Property corresponding to the
failFast(boolean) method. |
static String |
GETTER_PROPERTY_SELECTION_STRATEGY_CLASSNAME
Property for configuring the getter property selection strategy, allowing to set which rules will be applied
to determine if a method is a valid JavaBean getter.
|
static String |
LOCALE_RESOLVER_CLASSNAME
Property for configuring the locale resolver, allowing to select an implementation of
LocaleResolver
which will be used for locale resolution when interpolating a message. |
static String |
PROPERTY_NODE_NAME_PROVIDER_CLASSNAME
Property for configuring the property node name provider, allowing to select an implementation of
PropertyNodeNameProvider
which will be used for property name resolution when creating a property path. |
static String |
SCRIPT_EVALUATOR_FACTORY_CLASSNAME
Property for configuring the script evaluator factory, allowing to set up which factory will be used to create
ScriptEvaluator s for evaluation of script expressions in
ScriptAssert and ParameterScriptAssert
constraints. |
static String |
TEMPORAL_VALIDATION_TOLERANCE
Property for configuring temporal validation tolerance, allowing to set the acceptable margin of error when
comparing date/time in temporal constraints.
|
Modifier and Type | Method and Description |
---|---|
S |
addMapping(ConstraintMapping mapping)
Adds the specified
ConstraintMapping instance to the configuration. |
S |
allowMultipleCascadedValidationOnReturnValues(boolean allow)
Define whether more than one constraint on a return value may be marked for cascading validation are allowed.
|
S |
allowOverridingMethodAlterParameterConstraint(boolean allow)
Define whether overriding methods that override constraints should throw a
ConstraintDefinitionException . |
S |
allowParallelMethodsDefineParameterConstraints(boolean allow)
Define whether parallel methods that define constraints should throw a
ConstraintDefinitionException . |
S |
beanMetaDataClassNormalizer(BeanMetaDataClassNormalizer beanMetaDataClassNormalizer) |
S |
constraintExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel)
Allows setting the Expression Language feature level for message interpolation of constraint messages.
|
S |
constraintValidatorPayload(Object constraintValidatorPayload)
Allows to set a payload which will be passed to the constraint validators.
|
ConstraintMapping |
createConstraintMapping()
Creates a new constraint mapping which can be used to programmatically configure the constraints for given types.
|
S |
customViolationExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel)
Allows setting the Expression Language feature level for message interpolation of custom violation messages.
|
S |
defaultLocale(Locale defaultLocale)
Allows setting the default locale used to interpolate the constraint violation messages.
|
S |
enableTraversableResolverResultCache(boolean enabled)
Define whether the per validation call caching of
TraversableResolver results is enabled. |
S |
externalClassLoader(ClassLoader externalClassLoader)
Sets the class loader to be used for loading user-provided resources:
XML descriptors (
META-INF/validation.xml as well as XML constraint mappings)
classes specified by name in XML descriptors (e.g. |
S |
failFast(boolean failFast)
En- or disables the fail fast mode.
|
ResourceBundleLocator |
getDefaultResourceBundleLocator()
Returns the
ResourceBundleLocator used by the
default message
interpolator to load user-provided resource bundles. |
Set<ValueExtractor<?>> |
getDefaultValueExtractors()
Returns the default
ValueExtractor implementations as per the
specification. |
S |
getterPropertySelectionStrategy(GetterPropertySelectionStrategy getterPropertySelectionStrategy)
Allows to set a getter property selection strategy defining the rules determining if a method is a getter
or not.
|
S |
localeResolver(LocaleResolver localeResolver)
Allows setting a locale resolver, defining how the locale will be resolved when interpolating the message of a constraint violation.
|
default S |
locales(Locale... locales)
Allows setting the list of the locales supported by this ValidatorFactory.
|
S |
locales(Set<Locale> locales)
Allows setting the list of the locales supported by this ValidatorFactory.
|
S |
propertyNodeNameProvider(PropertyNodeNameProvider propertyNodeNameProvider)
Allows to set a property node name provider, defining how the name of a property node will be resolved
when constructing a property path as the one returned by
ConstraintViolation.getPropertyPath() . |
S |
scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory)
Allows to specify a custom
ScriptEvaluatorFactory responsible for creating ScriptEvaluator s
used to evaluate script expressions for ScriptAssert and ParameterScriptAssert constraints. |
S |
temporalValidationTolerance(Duration temporalValidationTolerance)
Allows to set the acceptable margin of error when comparing date/time in temporal constraints such as
Past /PastOrPresent and Future /FutureOrPresent . |
addMapping, addProperty, addValueExtractor, buildValidatorFactory, clockProvider, constraintValidatorFactory, getBootstrapConfiguration, getDefaultClockProvider, getDefaultConstraintValidatorFactory, getDefaultMessageInterpolator, getDefaultParameterNameProvider, getDefaultTraversableResolver, ignoreXmlConfiguration, messageInterpolator, parameterNameProvider, traversableResolver
static final String FAIL_FAST
static final String ALLOW_PARAMETER_CONSTRAINT_OVERRIDE
allowOverridingMethodAlterParameterConstraint(boolean)
method.
Accepts true
or false
.
Defaults to false
.static final String ALLOW_MULTIPLE_CASCADED_VALIDATION_ON_RESULT
allowMultipleCascadedValidationOnReturnValues(boolean)
method.
Accepts true
or false
.
Defaults to false
.static final String ALLOW_PARALLEL_METHODS_DEFINE_PARAMETER_CONSTRAINTS
allowParallelMethodsDefineParameterConstraints(boolean)
method.
Accepts true
or false
.
Defaults to false
.@Deprecated static final String CONSTRAINT_MAPPING_CONTRIBUTOR
static final String CONSTRAINT_MAPPING_CONTRIBUTORS
ConstraintMappingContributor
implementations.static final String ENABLE_TRAVERSABLE_RESOLVER_RESULT_CACHE
enableTraversableResolverResultCache(boolean)
.
Accepts true
or false
.
Defaults to true
.@Incubating static final String SCRIPT_EVALUATOR_FACTORY_CLASSNAME
ScriptEvaluator
s for evaluation of script expressions in
ScriptAssert
and ParameterScriptAssert
constraints. A fully qualified name of a class implementing ScriptEvaluatorFactory
is expected as a value.@Incubating static final String TEMPORAL_VALIDATION_TOLERANCE
@Incubating static final String GETTER_PROPERTY_SELECTION_STRATEGY_CLASSNAME
@Incubating static final String PROPERTY_NODE_NAME_PROVIDER_CLASSNAME
PropertyNodeNameProvider
which will be used for property name resolution when creating a property path.@Incubating static final String LOCALE_RESOLVER_CLASSNAME
LocaleResolver
which will be used for locale resolution when interpolating a message.@Incubating static final String CONSTRAINT_EXPRESSION_LANGUAGE_FEATURE_LEVEL
This property only affects the EL feature level of "static" constraint violation messages. In particular, it
doesn't affect the default EL feature level for custom violations. Refer to
CUSTOM_VIOLATION_EXPRESSION_LANGUAGE_FEATURE_LEVEL
to configure that.
@Incubating static final String CUSTOM_VIOLATION_EXPRESSION_LANGUAGE_FEATURE_LEVEL
ResourceBundleLocator getDefaultResourceBundleLocator()
Returns the ResourceBundleLocator
used by the
default message
interpolator
to load user-provided resource bundles. In conformance with
the specification this default locator retrieves the bundle
"ValidationMessages".
This locator can be used as delegate for custom locators when setting a
customized ResourceBundleMessageInterpolator
:
HibernateValidatorConfiguration configure =
Validation.byProvider(HibernateValidator.class).configure();
ResourceBundleLocator defaultResourceBundleLocator =
configure.getDefaultBundleLocator();
ResourceBundleLocator myResourceBundleLocator =
new MyResourceBundleLocator(defaultResourceBundleLocator);
configure.messageInterpolator(
new ResourceBundleMessageInterpolator(myResourceBundleLocator));
ResourceBundleLocator
. Never null.ConstraintMapping createConstraintMapping()
addMapping(ConstraintMapping)
.@Incubating Set<ValueExtractor<?>> getDefaultValueExtractors()
ValueExtractor
implementations as per the
specification.ValueExtractor
implementations compliant
with the specificationS addMapping(ConstraintMapping mapping)
ConstraintMapping
instance to the configuration. Constraints configured in mapping
will be added to the constraints configured via annotations and/or xml.mapping
- ConstraintMapping
instance containing programmatic configured constraintsthis
following the chaining method patternIllegalArgumentException
- if mapping
is null
S failFast(boolean failFast)
failFast
- true
to enable fail fast, false
otherwise.this
following the chaining method patternS externalClassLoader(ClassLoader externalClassLoader)
META-INF/validation.xml
as well as XML constraint mappings)ValidationMessages
resource bundleexternalClassLoader
- The class loader for loading user-provided resources.this
following the chaining method patternS allowOverridingMethodAlterParameterConstraint(boolean allow)
ConstraintDefinitionException
.
The default value is false
, i.e. do not allow.
See Section 4.5.5 of the JSR 380 specification, specifically
"In sub types (be it sub classes/interfaces or interface implementations), no parameter constraints may be declared on overridden or implemented methods, nor may parameters be marked for cascaded validation. This would pose a strengthening of preconditions to be fulfilled by the caller."
allow
- flag determining whether validation will allow overriding to alter parameter constraints.this
following the chaining method patternS allowMultipleCascadedValidationOnReturnValues(boolean allow)
false
, i.e. do not allow.
See Section 4.5.5 of the JSR 380 specification, specifically
"One must not mark a method return value for cascaded validation more than once in a line of a class hierarchy. In other words, overriding methods on sub types (be it sub classes/interfaces or interface implementations) cannot mark the return value for cascaded validation if the return value has already been marked on the overridden method of the super type or interface."
allow
- flag determining whether validation will allow multiple cascaded validation on return values.this
following the chaining method patternS allowParallelMethodsDefineParameterConstraints(boolean allow)
ConstraintDefinitionException
. The
default value is false
, i.e. do not allow.
See Section 4.5.5 of the JSR 380 specification, specifically
"If a sub type overrides/implements a method originally defined in several parallel types of the hierarchy (e.g. two interfaces not extending each other, or a class and an interface not implemented by said class), no parameter constraints may be declared for that method at all nor parameters be marked for cascaded validation. This again is to avoid an unexpected strengthening of preconditions to be fulfilled by the caller."
allow
- flag determining whether validation will allow parameter constraints in parallel hierarchiesthis
following the chaining method patternS enableTraversableResolverResultCache(boolean enabled)
TraversableResolver
results is enabled. The default
value is true
, i.e. the caching is enabled.
This behavior was initially introduced to cache the JPATraversableResolver
results but the map lookups it
introduces can be counterproductive when the TraversableResolver
calls are very fast.
enabled
- flag determining whether per validation call caching is enabled for TraversableResolver
results.this
following the chaining method pattern@Incubating S scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory)
ScriptEvaluatorFactory
responsible for creating ScriptEvaluator
s
used to evaluate script expressions for ScriptAssert
and ParameterScriptAssert
constraints.scriptEvaluatorFactory
- the ScriptEvaluatorFactory
to be usedthis
following the chaining method pattern@Incubating S temporalValidationTolerance(Duration temporalValidationTolerance)
Past
/PastOrPresent
and Future
/FutureOrPresent
.temporalValidationTolerance
- the acceptable tolerancethis
following the chaining method pattern@Incubating S constraintValidatorPayload(Object constraintValidatorPayload)
constraintValidatorPayload
- the payload passed to constraint validatorsthis
following the chaining method pattern@Incubating S getterPropertySelectionStrategy(GetterPropertySelectionStrategy getterPropertySelectionStrategy)
getterPropertySelectionStrategy
- the GetterPropertySelectionStrategy
to be usedthis
following the chaining method pattern@Incubating S propertyNodeNameProvider(PropertyNodeNameProvider propertyNodeNameProvider)
ConstraintViolation.getPropertyPath()
.propertyNodeNameProvider
- the PropertyNodeNameProvider
to be usedthis
following the chaining method pattern@Incubating S locales(Set<Locale> locales)
Can be used for advanced locale resolution and/or to force the initialization of the resource bundles at bootstrap.
If not set, defaults to a singleton containing Locale.getDefault()
.
@Incubating default S locales(Locale... locales)
Can be used for advanced locale resolution and/or to force the initialization of the resource bundles at bootstrap.
If not set, defaults to a singleton containing Locale.getDefault()
.
@Incubating S defaultLocale(Locale defaultLocale)
If not set, defaults to the system locale obtained via Locale.getDefault()
.
@Incubating S localeResolver(LocaleResolver localeResolver)
localeResolver
- the LocaleResolver
to be usedthis
following the chaining method pattern@Incubating S beanMetaDataClassNormalizer(BeanMetaDataClassNormalizer beanMetaDataClassNormalizer)
@Incubating S constraintExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel)
This is the feature level used for messages hardcoded inside the constraint declaration.
If you are creating custom constraint violations, Expression Language support needs to be explicitly enabled and use the safest feature level by default if enabled.
expressionLanguageFeatureLevel
- the ExpressionLanguageFeatureLevel
to be usedthis
following the chaining method pattern@Incubating S customViolationExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel)
This is the feature level used for messages of custom violations created by the ConstraintValidatorContext
.
expressionLanguageFeatureLevel
- the ExpressionLanguageFeatureLevel
to be usedthis
following the chaining method patternCopyright © 2007-2021 Red Hat, Inc. All Rights Reserved