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.
use hibernate.validator.constraint_mapping_contributors instead
|
static String |
CONSTRAINT_MAPPING_CONTRIBUTORS
Property for configuring a constraint mapping contributor, allowing to set up one or more constraint mappings for
the default validator factory.
|
static String |
FAIL_FAST
Property corresponding to the
failFast(boolean) method. |
static String |
TIME_PROVIDER
Property corresponding to the
timeProvider(TimeProvider) method. |
static String |
VALIDATED_VALUE_HANDLERS
Property corresponding to the
addValidatedValueHandler(ValidatedValueUnwrapper) method. |
Modifier and Type | Method and Description |
---|---|
HibernateValidatorConfiguration |
addMapping(ConstraintMapping mapping)
Adds the specified
ConstraintMapping instance to the configuration. |
HibernateValidatorConfiguration |
addValidatedValueHandler(ValidatedValueUnwrapper<?> handler)
Registers the given validated value unwrapper with the bootstrapped validator factory.
|
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 . |
ConstraintMapping |
createConstraintMapping()
Creates a new constraint mapping which can be used to programmatically configure the constraints for given types.
|
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. |
HibernateValidatorConfiguration |
timeProvider(TimeProvider timeProvider)
Registers the given time provider with the bootstrapped validator factory.
|
addMapping, addProperty, buildValidatorFactory, constraintValidatorFactory, getBootstrapConfiguration, 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
.static final String VALIDATED_VALUE_HANDLERS
addValidatedValueHandler(ValidatedValueUnwrapper)
method. Accepts a String
with the comma-separated fully-qualified names of one or more ValidatedValueUnwrapper
implementations.@Deprecated static final String CONSTRAINT_MAPPING_CONTRIBUTOR
ConstraintMappingContributor
implementation.static final String CONSTRAINT_MAPPING_CONTRIBUTORS
ConstraintMappingContributor
implementations.static final String TIME_PROVIDER
timeProvider(TimeProvider)
method. Accepts a String with the
fully-qualified class name of a TimeProvider
implementation.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)
.HibernateValidatorConfiguration 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
HibernateValidatorConfiguration failFast(boolean failFast)
failFast
- true
to enable fail fast, false
otherwise.this
following the chaining method patternHibernateValidatorConfiguration addValidatedValueHandler(ValidatedValueUnwrapper<?> handler)
UnwrapValidatedValue
, the unwrapper will be applied to retrieve the
value to validate.handler
- the unwrapper to registerthis
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 timeProvider(TimeProvider timeProvider)
@Future
and @Past
constraints. By default the current system
time and the current default time zone will be used when validating these constraints.timeProvider
- the time provider to register. Must not be null
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 349 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 349 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 349 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 patternCopyright © 2017 JBoss by Red Hat. All rights reserved.