public interface HibernateValidatorConfiguration extends Configuration<HibernateValidatorConfiguration>
| 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_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 |
ENABLE_TRAVERSABLE_RESOLVER_RESULT_CACHE
Property corresponding to the
enableTraversableResolverResultCache(boolean). |
static String |
FAIL_FAST
Property corresponding to the
failFast(boolean) method. |
static String |
SCRIPT_EVALUATOR_FACTORY_CLASSNAME
Property for configuring the script evaluator factory, allowing to set up which factory will be used to create
ScriptEvaluators 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 |
|---|---|
HibernateValidatorConfiguration |
addMapping(ConstraintMapping mapping)
Adds the specified
ConstraintMapping instance to the configuration. |
HibernateValidatorConfiguration |
allowMultipleCascadedValidationOnReturnValues(boolean allow)
Define whether more than one constraint on a return value may be marked for cascading validation are allowed.
|
HibernateValidatorConfiguration |
allowOverridingMethodAlterParameterConstraint(boolean allow)
Define whether overriding methods that override constraints should throw a
ConstraintDefinitionException. |
HibernateValidatorConfiguration |
allowParallelMethodsDefineParameterConstraints(boolean allow)
Define whether parallel methods that define constraints should throw a
ConstraintDefinitionException. |
HibernateValidatorConfiguration |
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.
|
HibernateValidatorConfiguration |
enableTraversableResolverResultCache(boolean enabled)
Define whether the per validation call caching of
TraversableResolver results is enabled. |
HibernateValidatorConfiguration |
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. |
HibernateValidatorConfiguration |
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. |
HibernateValidatorConfiguration |
scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory)
Allows to specify a custom
ScriptEvaluatorFactory responsible for creating ScriptEvaluators
used to evaluate script expressions for ScriptAssert and ParameterScriptAssert constraints. |
HibernateValidatorConfiguration |
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, traversableResolverstatic 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
ScriptEvaluators 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
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 specificationHibernateValidatorConfiguration 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 nullHibernateValidatorConfiguration failFast(boolean failFast)
failFast - true to enable fail fast, false otherwise.this following the chaining method patternHibernateValidatorConfiguration 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 patternHibernateValidatorConfiguration 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 patternHibernateValidatorConfiguration 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 patternHibernateValidatorConfiguration 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 patternHibernateValidatorConfiguration 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 HibernateValidatorConfiguration scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory)
ScriptEvaluatorFactory responsible for creating ScriptEvaluators
used to evaluate script expressions for ScriptAssert and ParameterScriptAssert constraints.scriptEvaluatorFactory - the ScriptEvaluatorFactory to be usedthis following the chaining method pattern@Incubating HibernateValidatorConfiguration temporalValidationTolerance(Duration temporalValidationTolerance)
Past/PastOrPresent and Future/FutureOrPresent.temporalValidationTolerance - the acceptable tolerancethis following the chaining method pattern@Incubating HibernateValidatorConfiguration constraintValidatorPayload(Object constraintValidatorPayload)
constraintValidatorPayload - the payload passed to constraint validatorsthis following the chaining method patternCopyright © 2019 JBoss by Red Hat. All rights reserved.