+ * Should not be used directly, prefer {@link HibernateValidatorConfiguration} or
+ * {@link PredefinedScopeHibernateValidatorConfiguration}.
+ *
+ * @author Emmanuel Bernard
+ * @author Gunnar Morling
+ * @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI
+ * @author Hardy Ferentschik
+ * @author Chris Beckey <cbeckey@paypal.com>
+ */
+public interface BaseHibernateValidatorConfiguration> extends Configuration {
+ /**
+ * Property corresponding to the {@link #failFast} method.
+ * Accepts {@code true} or {@code false}. Defaults to {@code false}.
+ */
+ String FAIL_FAST = "hibernate.validator.fail_fast";
+
+ /**
+ * Property corresponding to the {@link #allowOverridingMethodAlterParameterConstraint} method.
+ * Accepts {@code true} or {@code false}.
+ * Defaults to {@code false}.
+ */
+ String ALLOW_PARAMETER_CONSTRAINT_OVERRIDE = "hibernate.validator.allow_parameter_constraint_override";
+
+ /**
+ * Property corresponding to the {@link #allowMultipleCascadedValidationOnReturnValues} method.
+ * Accepts {@code true} or {@code false}.
+ * Defaults to {@code false}.
+ */
+ String ALLOW_MULTIPLE_CASCADED_VALIDATION_ON_RESULT = "hibernate.validator.allow_multiple_cascaded_validation_on_result";
+
+ /**
+ * Property corresponding to the {@link #allowParallelMethodsDefineParameterConstraints} method.
+ * Accepts {@code true} or {@code false}.
+ * Defaults to {@code false}.
+ */
+ String ALLOW_PARALLEL_METHODS_DEFINE_PARAMETER_CONSTRAINTS = "hibernate.validator.allow_parallel_method_parameter_constraint";
+
+ /**
+ * @deprecated planned for removal. Use hibernate.validator.constraint_mapping_contributors instead.
+ * @since 5.2
+ */
+ @Deprecated
+ String CONSTRAINT_MAPPING_CONTRIBUTOR = "hibernate.validator.constraint_mapping_contributor";
+
+ /**
+ * Property for configuring constraint mapping contributors, allowing to set up one or more constraint mappings for
+ * the default validator factory. Accepts a String with the comma separated fully-qualified class names of one or more
+ * {@link org.hibernate.validator.spi.cfg.ConstraintMappingContributor} implementations.
+ *
+ * @since 5.3
+ */
+ String CONSTRAINT_MAPPING_CONTRIBUTORS = "hibernate.validator.constraint_mapping_contributors";
+
+ /**
+ * Property corresponding to the {@link #enableTraversableResolverResultCache(boolean)}.
+ * Accepts {@code true} or {@code false}.
+ * Defaults to {@code true}.
+ *
+ * @since 6.0.3
+ */
+ String ENABLE_TRAVERSABLE_RESOLVER_RESULT_CACHE = "hibernate.validator.enable_traversable_resolver_result_cache";
+
+ /**
+ * Property for configuring the script evaluator factory, allowing to set up which factory will be used to create
+ * {@link ScriptEvaluator}s for evaluation of script expressions in
+ * {@link ScriptAssert} and {@link ParameterScriptAssert}
+ * constraints. A fully qualified name of a class implementing {@link ScriptEvaluatorFactory} is expected as a value.
+ *
+ * @since 6.0.3
+ */
+ @Incubating
+ String SCRIPT_EVALUATOR_FACTORY_CLASSNAME = "hibernate.validator.script_evaluator_factory";
+
+ /**
+ * Property for configuring temporal validation tolerance, allowing to set the acceptable margin of error when
+ * comparing date/time in temporal constraints. In milliseconds.
+ *
+ * @since 6.0.5
+ */
+ @Incubating
+ String TEMPORAL_VALIDATION_TOLERANCE = "hibernate.validator.temporal_validation_tolerance";
+
+ /**
+ * 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.
+ *
+ * @since 6.1.0
+ */
+ @Incubating
+ String GETTER_PROPERTY_SELECTION_STRATEGY_CLASSNAME = "hibernate.validator.getter_property_selection_strategy";
+
+ /**
+ * Property for configuring the property node name provider, allowing to select an implementation of {@link PropertyNodeNameProvider}
+ * which will be used for property name resolution when creating a property path.
+ *
+ * @since 6.1.0
+ */
+ @Incubating
+ String PROPERTY_NODE_NAME_PROVIDER_CLASSNAME = "hibernate.validator.property_node_name_provider";
+
+ /**
+ *
+ * Returns the {@link ResourceBundleLocator} used by the + * {@link Configuration#getDefaultMessageInterpolator() 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 {@link org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator}: + *
+ *+ * {@code + * HibernateValidatorConfiguration configure = + * Validation.byProvider(HibernateValidator.class).configure(); + * + * ResourceBundleLocator defaultResourceBundleLocator = + * configure.getDefaultBundleLocator(); + * ResourceBundleLocator myResourceBundleLocator = + * new MyResourceBundleLocator(defaultResourceBundleLocator); + * + * configure.messageInterpolator( + * new ResourceBundleMessageInterpolator(myResourceBundleLocator)); + * } + *+ * + * @return The default {@link ResourceBundleLocator}. Never null. + */ + ResourceBundleLocator getDefaultResourceBundleLocator(); + + /** + * Creates a new constraint mapping which can be used to programmatically configure the constraints for given types. After + * the mapping has been set up, it must be added to this configuration via {@link #addMapping(ConstraintMapping)}. + * + * @return A new constraint mapping. + */ + ConstraintMapping createConstraintMapping(); + + /** + * Returns the default {@link ValueExtractor} implementations as per the + * specification. + * + * @return the default {@code ValueExtractor} implementations compliant + * with the specification + * + * @since 6.0 + */ + @Incubating + Set
+ * 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." + *+ * + * @param allow flag determining whether validation will allow overriding to alter parameter constraints. + * + * @return {@code this} following the chaining method pattern + * + * @since 5.3 + */ + S allowOverridingMethodAlterParameterConstraint(boolean allow); + + /** + * Define whether more than one constraint on a return value may be marked for cascading validation are allowed. + * The default value is {@code 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." + *+ * + * @param allow flag determining whether validation will allow multiple cascaded validation on return values. + * + * @return {@code this} following the chaining method pattern + * + * @since 5.3 + */ + S allowMultipleCascadedValidationOnReturnValues(boolean allow); + + /** + * Define whether parallel methods that define constraints should throw a {@code ConstraintDefinitionException}. The + * default value is {@code 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." + *+ * + * @param allow flag determining whether validation will allow parameter constraints in parallel hierarchies + * + * @return {@code this} following the chaining method pattern + * + * @since 5.3 + */ + S allowParallelMethodsDefineParameterConstraints(boolean allow); + + /** + * Define whether the per validation call caching of {@link TraversableResolver} results is enabled. The default + * value is {@code true}, i.e. the caching is enabled. + *
+ * This behavior was initially introduced to cache the {@code JPATraversableResolver} results but the map lookups it
+ * introduces can be counterproductive when the {@code TraversableResolver} calls are very fast.
+ *
+ * @param enabled flag determining whether per validation call caching is enabled for {@code TraversableResolver}
+ * results.
+ *
+ * @return {@code this} following the chaining method pattern
+ *
+ * @since 6.0.3
+ */
+ S enableTraversableResolverResultCache(boolean enabled);
+
+ /**
+ * Allows to specify a custom {@link ScriptEvaluatorFactory} responsible for creating {@link ScriptEvaluator}s
+ * used to evaluate script expressions for {@link ScriptAssert} and {@link ParameterScriptAssert} constraints.
+ *
+ * @param scriptEvaluatorFactory the {@link ScriptEvaluatorFactory} to be used
+ *
+ * @return {@code this} following the chaining method pattern
+ *
+ * @since 6.0.3
+ */
+ @Incubating
+ S scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory);
+
+ /**
+ * Allows to set the acceptable margin of error when comparing date/time in temporal constraints such as
+ * {@link Past}/{@link PastOrPresent} and {@link Future}/{@link FutureOrPresent}.
+ *
+ * @param temporalValidationTolerance the acceptable tolerance
+ *
+ * @return {@code this} following the chaining method pattern
+ *
+ * @since 6.0.5
+ */
+ @Incubating
+ S temporalValidationTolerance(Duration temporalValidationTolerance);
+
+ /**
+ * Allows to set a payload which will be passed to the constraint validators. If the method is called multiple
+ * times, only the payload passed last will be propagated.
+ *
+ * @param constraintValidatorPayload the payload passed to constraint validators
+ *
+ * @return {@code this} following the chaining method pattern
+ *
+ * @since 6.0.8
+ */
+ @Incubating
+ S constraintValidatorPayload(Object constraintValidatorPayload);
+
+ /**
+ * Allows to set a getter property selection strategy defining the rules determining if a method is a getter
+ * or not.
+ *
+ * @param getterPropertySelectionStrategy the {@link GetterPropertySelectionStrategy} to be used
+ *
+ * @return {@code this} following the chaining method pattern
+ *
+ * @since 6.1.0
+ */
+ @Incubating
+ S getterPropertySelectionStrategy(GetterPropertySelectionStrategy getterPropertySelectionStrategy);
+
+ /**
+ * 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 {@link ConstraintViolation#getPropertyPath()}.
+ *
+ * @param propertyNodeNameProvider the {@link PropertyNodeNameProvider} to be used
+ *
+ * @return {@code this} following the chaining method pattern
+ *
+ * @since 6.1.0
+ */
+ @Incubating
+ S propertyNodeNameProvider(PropertyNodeNameProvider propertyNodeNameProvider);
+}
diff --git a/engine/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java b/engine/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java
index 45773d3949..186a7e150e 100644
--- a/engine/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java
+++ b/engine/src/main/java/org/hibernate/validator/HibernateValidatorConfiguration.java
@@ -6,309 +6,12 @@
*/
package org.hibernate.validator;
-import java.time.Duration;
-import java.util.Set;
-
-import javax.validation.Configuration;
-import javax.validation.TraversableResolver;
-import javax.validation.constraints.Future;
-import javax.validation.constraints.FutureOrPresent;
-import javax.validation.constraints.Past;
-import javax.validation.constraints.PastOrPresent;
-import javax.validation.valueextraction.ValueExtractor;
-
-import org.hibernate.validator.cfg.ConstraintMapping;
-import org.hibernate.validator.constraints.ParameterScriptAssert;
-import org.hibernate.validator.constraints.ScriptAssert;
-import org.hibernate.validator.spi.resourceloading.ResourceBundleLocator;
-import org.hibernate.validator.spi.scripting.ScriptEvaluator;
-import org.hibernate.validator.spi.scripting.ScriptEvaluatorFactory;
-
/**
* Uniquely identifies Hibernate Validator in the Bean Validation bootstrap
* strategy. Also contains Hibernate Validator specific configurations.
*
- * @author Emmanuel Bernard
- * @author Gunnar Morling
- * @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI
- * @author Hardy Ferentschik
- * @author Chris Beckey <cbeckey@paypal.com>
+ * @author Guillaume Smet
*/
-public interface HibernateValidatorConfiguration extends Configuration
- * Returns the {@link ResourceBundleLocator} used by the
- * {@link Configuration#getDefaultMessageInterpolator() 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 {@link org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator}:
- *
- * See Section 4.5.5 of the JSR 380 specification, specifically
- *
- * See Section 4.5.5 of the JSR 380 specification, specifically
- *
- * See Section 4.5.5 of the JSR 380 specification, specifically
- *
- * This behavior was initially introduced to cache the {@code JPATraversableResolver} results but the map lookups it
- * introduces can be counterproductive when the {@code TraversableResolver} calls are very fast.
- *
- * @param enabled flag determining whether per validation call caching is enabled for {@code TraversableResolver}
- * results.
- *
- * @return {@code this} following the chaining method pattern
- *
- * @since 6.0.3
- */
- HibernateValidatorConfiguration enableTraversableResolverResultCache(boolean enabled);
-
- /**
- * Allows to specify a custom {@link ScriptEvaluatorFactory} responsible for creating {@link ScriptEvaluator}s
- * used to evaluate script expressions for {@link ScriptAssert} and {@link ParameterScriptAssert} constraints.
- *
- * @param scriptEvaluatorFactory the {@link ScriptEvaluatorFactory} to be used
- *
- * @return {@code this} following the chaining method pattern
- *
- * @since 6.0.3
- */
- @Incubating
- HibernateValidatorConfiguration scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory);
-
- /**
- * Allows to set the acceptable margin of error when comparing date/time in temporal constraints such as
- * {@link Past}/{@link PastOrPresent} and {@link Future}/{@link FutureOrPresent}.
- *
- * @param temporalValidationTolerance the acceptable tolerance
- *
- * @return {@code this} following the chaining method pattern
- *
- * @since 6.0.5
- */
- @Incubating
- HibernateValidatorConfiguration temporalValidationTolerance(Duration temporalValidationTolerance);
+public interface HibernateValidatorConfiguration extends BaseHibernateValidatorConfiguration
+ * It allows to collect all the necessary metadata at bootstrap.
+ *
+ * @author Guillaume Smet
+ *
+ * @since 6.1
+ */
+@Incubating
+public class PredefinedScopeHibernateValidator implements ValidationProvider
* Until this method is called constraints apply on class level. After calling this method constraints
* apply on the specified property with the given access type.
- *
* A given property may only be configured once.
- *
+ * Until this method is called constraints apply on class level. After calling this method constraints
+ * apply on the specified field property.
+ *
+ * A given field may only be configured once.
+ *
+ * @param property The field name that represents a property on which to apply the following constraints.
+ *
+ * @return A creational context representing the selected field property.
+ */
+ PropertyConstraintMappingContext field(String property);
+
+ /**
+ * Selects a getter to which the next operations shall apply.
+ *
+ * Until this method is called constraints apply on class level. After calling this method constraints
+ * apply on the specified getter property.
+ *
+ * A given getter may only be configured once.
+ *
+ * @param property The getter property name (using the Java Bean notation, e.g. {@code name} to address {@code getName()})
+ * that represents a property on which to apply the following constraints.
+ *
+ * @return A creational context representing the selected getter property.
+ */
+ PropertyConstraintMappingContext getter(String property);
}
diff --git a/engine/src/main/java/org/hibernate/validator/cfg/context/ReturnValueTarget.java b/engine/src/main/java/org/hibernate/validator/cfg/context/ReturnValueTarget.java
index b632c6dc22..46a5e4b39b 100644
--- a/engine/src/main/java/org/hibernate/validator/cfg/context/ReturnValueTarget.java
+++ b/engine/src/main/java/org/hibernate/validator/cfg/context/ReturnValueTarget.java
@@ -7,7 +7,7 @@
package org.hibernate.validator.cfg.context;
/**
- * Facet of a constraint mapping creational context which allows to the select the current method's or constructor's
+ * Facet of a constraint mapping creational context which allows to select the current method's or constructor's
* return value as target for the next operations.
*
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI
diff --git a/engine/src/main/java/org/hibernate/validator/cfg/context/TypeConstraintMappingContext.java b/engine/src/main/java/org/hibernate/validator/cfg/context/TypeConstraintMappingContext.java
index 4655d18855..aa3495daa7 100644
--- a/engine/src/main/java/org/hibernate/validator/cfg/context/TypeConstraintMappingContext.java
+++ b/engine/src/main/java/org/hibernate/validator/cfg/context/TypeConstraintMappingContext.java
@@ -18,6 +18,7 @@
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI
* @author Gunnar Morling
*/
+@SuppressWarnings("deprecation")
public interface TypeConstraintMappingContext
+ * Using {@link Type#ANY} allows to validate values that could either be ISBN10 or ISBN13.
+ * In such case, ISBN type would be determined by the length of the corresponding value.
*/
enum Type {
ISBN_10,
- ISBN_13
+ ISBN_13,
+ ANY
}
}
diff --git a/engine/src/main/java/org/hibernate/validator/constraints/ModCheck.java b/engine/src/main/java/org/hibernate/validator/constraints/ModCheck.java
index c055b19c21..6c3cf28697 100644
--- a/engine/src/main/java/org/hibernate/validator/constraints/ModCheck.java
+++ b/engine/src/main/java/org/hibernate/validator/constraints/ModCheck.java
@@ -22,8 +22,6 @@
import javax.validation.Constraint;
import javax.validation.Payload;
-import org.hibernate.validator.constraints.ModCheck.List;
-
/**
* Modulo check constraint.
*
@@ -42,7 +40,7 @@
@Constraint(validatedBy = { })
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
-@Repeatable(List.class)
+@Repeatable(ModCheck.List.class)
public @interface ModCheck {
String message() default "{org.hibernate.validator.constraints.ModCheck.message}";
diff --git a/engine/src/main/java/org/hibernate/validator/constraints/NotBlank.java b/engine/src/main/java/org/hibernate/validator/constraints/NotBlank.java
index b39bf68afb..52da079478 100644
--- a/engine/src/main/java/org/hibernate/validator/constraints/NotBlank.java
+++ b/engine/src/main/java/org/hibernate/validator/constraints/NotBlank.java
@@ -24,8 +24,6 @@
import javax.validation.ReportAsSingleViolation;
import javax.validation.constraints.NotNull;
-import org.hibernate.validator.constraints.NotBlank.List;
-
/**
* Validate that the annotated string is not {@code null} or empty.
* The difference to {@code NotEmpty} is that trailing whitespaces are getting ignored.
@@ -40,7 +38,7 @@
@Retention(RUNTIME)
@ReportAsSingleViolation
@NotNull
-@Repeatable(List.class)
+@Repeatable(NotBlank.List.class)
@Deprecated
public @interface NotBlank {
String message() default "{org.hibernate.validator.constraints.NotBlank.message}";
diff --git a/engine/src/main/java/org/hibernate/validator/constraints/NotEmpty.java b/engine/src/main/java/org/hibernate/validator/constraints/NotEmpty.java
index d44e03d4d8..b6c19d1845 100644
--- a/engine/src/main/java/org/hibernate/validator/constraints/NotEmpty.java
+++ b/engine/src/main/java/org/hibernate/validator/constraints/NotEmpty.java
@@ -27,8 +27,6 @@
import javax.validation.constraintvalidation.SupportedValidationTarget;
import javax.validation.constraintvalidation.ValidationTarget;
-import org.hibernate.validator.constraints.NotEmpty.List;
-
/**
* Asserts that the annotated string, collection, map or array is not {@code null} or empty.
*
@@ -42,7 +40,7 @@
@SupportedValidationTarget(ValidationTarget.ANNOTATED_ELEMENT)
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
-@Repeatable(List.class)
+@Repeatable(NotEmpty.List.class)
@ReportAsSingleViolation
@NotNull
@Size(min = 1)
diff --git a/engine/src/main/java/org/hibernate/validator/constraints/ParameterScriptAssert.java b/engine/src/main/java/org/hibernate/validator/constraints/ParameterScriptAssert.java
index 889eecd16a..d15c7d833c 100644
--- a/engine/src/main/java/org/hibernate/validator/constraints/ParameterScriptAssert.java
+++ b/engine/src/main/java/org/hibernate/validator/constraints/ParameterScriptAssert.java
@@ -33,15 +33,16 @@
* ("Scripting for the JavaTM Platform") compatible engine can be
* found on the classpath. To refer to a parameter within the scripting
* expression, use its name as obtained by the active
- * {@link javax.validation.ParameterNameProvider}. By default, {@code arg0}, {@code arg1} etc.
- * will be used as parameter names.
+ * {@link javax.validation.ParameterNameProvider}. The default provider will
+ * return the actual parameter names, if the -parameters compiler option
+ * has been enabled, and {@code arg0}, {@code arg1} etc. otherwise.
*
* The following listing shows an example using the JavaScript engine which
* comes with the JDK:
*
+ * It is important to keep in mind that in case of explicit implementation of this interface
+ * access to all possible constrained getters and fields should be provided, for a class implementing
+ * the interface and all its super classes as well. Otherwise unexpected {@link IllegalArgumentException}
+ * could be thrown by the Hibernate Validator engine.
+ *
+ * @author Marko Bekhta
+ * @since 6.1
+ */
+@Incubating
+public interface HibernateValidatorEnhancedBean {
+
+ String GET_FIELD_VALUE_METHOD_NAME = "$$_hibernateValidator_getFieldValue";
+
+ String GET_GETTER_VALUE_METHOD_NAME = "$$_hibernateValidator_getGetterValue";
+
+ /**
+ * @param name the name of a field property of interest.
+ *
+ * @return the value of the field named {@code name} of the current bean.
+ *
+ * @throws IllegalArgumentException in case no field could be found for the given name.
+ */
+ Object $$_hibernateValidator_getFieldValue(String name);
+
+ /**
+ * @param name the name of a getter of interest.
+ *
+ * @return the value returned by the getter named {@code name} of the current bean.
+ *
+ * @throws IllegalArgumentException in case when no getter property could be found for the given name.
+ */
+ Object $$_hibernateValidator_getGetterValue(String name);
+}
diff --git a/engine/src/main/java/org/hibernate/validator/internal/cfg/context/PropertyConstraintMappingContextImpl.java b/engine/src/main/java/org/hibernate/validator/internal/cfg/context/AbstractPropertyConstraintMappingContextImpl.java
similarity index 52%
rename from engine/src/main/java/org/hibernate/validator/internal/cfg/context/PropertyConstraintMappingContextImpl.java
rename to engine/src/main/java/org/hibernate/validator/internal/cfg/context/AbstractPropertyConstraintMappingContextImpl.java
index dcb6681ce5..056470024c 100644
--- a/engine/src/main/java/org/hibernate/validator/internal/cfg/context/PropertyConstraintMappingContextImpl.java
+++ b/engine/src/main/java/org/hibernate/validator/internal/cfg/context/AbstractPropertyConstraintMappingContextImpl.java
@@ -7,26 +7,16 @@
package org.hibernate.validator.internal.cfg.context;
import java.lang.annotation.ElementType;
-import java.lang.reflect.Executable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import org.hibernate.validator.cfg.ConstraintDef;
import org.hibernate.validator.cfg.context.ConstructorConstraintMappingContext;
import org.hibernate.validator.cfg.context.ContainerElementConstraintMappingContext;
import org.hibernate.validator.cfg.context.MethodConstraintMappingContext;
import org.hibernate.validator.cfg.context.PropertyConstraintMappingContext;
-import org.hibernate.validator.internal.engine.valueextraction.ValueExtractorManager;
-import org.hibernate.validator.internal.metadata.core.ConstraintHelper;
+import org.hibernate.validator.internal.engine.ConstraintCreationContext;
import org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.ConstraintType;
import org.hibernate.validator.internal.metadata.location.ConstraintLocation;
-import org.hibernate.validator.internal.metadata.raw.ConfigurationSource;
import org.hibernate.validator.internal.metadata.raw.ConstrainedElement;
-import org.hibernate.validator.internal.metadata.raw.ConstrainedExecutable;
-import org.hibernate.validator.internal.metadata.raw.ConstrainedField;
-import org.hibernate.validator.internal.util.ReflectionHelper;
-import org.hibernate.validator.internal.util.TypeResolutionHelper;
+import org.hibernate.validator.internal.properties.Property;
/**
* Constraint mapping creational context which allows to configure the constraints for one bean property.
@@ -34,69 +24,58 @@
* @author Hardy Ferentschik
* @author Gunnar Morling
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI
+ * @author Marko Bekhta
*/
-final class PropertyConstraintMappingContextImpl
+abstract class AbstractPropertyConstraintMappingContextImpl
diff --git a/engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/bv/money/DigitsValidatorForMonetaryAmount.java b/engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/bv/money/DigitsValidatorForMonetaryAmount.java
new file mode 100644
index 0000000000..f46ddd81bc
--- /dev/null
+++ b/engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/bv/money/DigitsValidatorForMonetaryAmount.java
@@ -0,0 +1,62 @@
+/*
+ * Hibernate Validator, declare and validate application constraints
+ *
+ * License: Apache License, Version 2.0
+ * See the license.txt file in the root directory or
- * {@code
- * HibernateValidatorConfiguration configure =
- * Validation.byProvider(HibernateValidator.class).configure();
- *
- * ResourceBundleLocator defaultResourceBundleLocator =
- * configure.getDefaultBundleLocator();
- * ResourceBundleLocator myResourceBundleLocator =
- * new MyResourceBundleLocator(defaultResourceBundleLocator);
- *
- * configure.messageInterpolator(
- * new ResourceBundleMessageInterpolator(myResourceBundleLocator));
- * }
- *
- *
- * @return The default {@link ResourceBundleLocator}. Never null.
- */
- ResourceBundleLocator getDefaultResourceBundleLocator();
-
- /**
- * Creates a new constraint mapping which can be used to programmatically configure the constraints for given types. After
- * the mapping has been set up, it must be added to this configuration via {@link #addMapping(ConstraintMapping)}.
- *
- * @return A new constraint mapping.
- */
- ConstraintMapping createConstraintMapping();
-
- /**
- * Returns the default {@link ValueExtractor} implementations as per the
- * specification.
- *
- * @return the default {@code ValueExtractor} implementations compliant
- * with the specification
- *
- * @since 6.0
- */
- @Incubating
- Set
- *
- * If no class loader is given, these resources will be obtained through the thread context class loader and as a
- * last fallback through Hibernate Validator's own class loader.
- *
- * @param externalClassLoader The class loader for loading user-provided resources.
- *
- * @return {@code this} following the chaining method pattern
- *
- * @since 5.2
- */
- HibernateValidatorConfiguration externalClassLoader(ClassLoader externalClassLoader);
-
- /**
- * Define whether overriding methods that override constraints should throw a {@code ConstraintDefinitionException}.
- * The default value is {@code false}, i.e. do not allow.
- *
- * "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."
- *
- *
- * @param allow flag determining whether validation will allow overriding to alter parameter constraints.
- *
- * @return {@code this} following the chaining method pattern
- *
- * @since 5.3
- */
- HibernateValidatorConfiguration allowOverridingMethodAlterParameterConstraint(boolean allow);
-
- /**
- * Define whether more than one constraint on a return value may be marked for cascading validation are allowed.
- * The default value is {@code false}, i.e. do not allow.
- *
- * "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."
- *
- *
- * @param allow flag determining whether validation will allow multiple cascaded validation on return values.
- *
- * @return {@code this} following the chaining method pattern
- *
- * @since 5.3
- */
- HibernateValidatorConfiguration allowMultipleCascadedValidationOnReturnValues(boolean allow);
-
- /**
- * Define whether parallel methods that define constraints should throw a {@code ConstraintDefinitionException}. The
- * default value is {@code false}, i.e. do not allow.
- *
- * "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."
- *
- *
- * @param allow flag determining whether validation will allow parameter constraints in parallel hierarchies
- *
- * @return {@code this} following the chaining method pattern
- *
- * @since 5.3
- */
- HibernateValidatorConfiguration allowParallelMethodsDefineParameterConstraints(boolean allow);
-
- /**
- * Define whether the per validation call caching of {@link TraversableResolver} results is enabled. The default
- * value is {@code true}, i.e. the caching is enabled.
- *
- * {@code @ParameterScriptAssert(script = "arg0.before(arg1)", lang = "javascript")
+ * {@code @ParameterScriptAssert(script = "start.before(end)", lang = "javascript")
* public void createEvent(Date start, Date end) { ... }
* }
*
diff --git a/engine/src/main/java/org/hibernate/validator/constraints/SafeHtml.java b/engine/src/main/java/org/hibernate/validator/constraints/SafeHtml.java
index fa08e2fa81..86d7848cec 100644
--- a/engine/src/main/java/org/hibernate/validator/constraints/SafeHtml.java
+++ b/engine/src/main/java/org/hibernate/validator/constraints/SafeHtml.java
@@ -34,12 +34,14 @@
* {@code body} tags to the used whitelist as required.
*
* @author George Gastaldi
+ * @deprecated {@code @SafeHtml} support will be removed in a future version
*/
@Documented
@Constraint(validatedBy = { })
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Repeatable(List.class)
+@Deprecated
public @interface SafeHtml {
String message() default "{org.hibernate.validator.constraints.SafeHtml.message}";
diff --git a/engine/src/main/java/org/hibernate/validator/constraintvalidation/HibernateCrossParameterConstraintValidatorContext.java b/engine/src/main/java/org/hibernate/validator/constraintvalidation/HibernateCrossParameterConstraintValidatorContext.java
new file mode 100644
index 0000000000..b7ad51c76b
--- /dev/null
+++ b/engine/src/main/java/org/hibernate/validator/constraintvalidation/HibernateCrossParameterConstraintValidatorContext.java
@@ -0,0 +1,28 @@
+/*
+ * Hibernate Validator, declare and validate application constraints
+ *
+ * License: Apache License, Version 2.0
+ * See the license.txt file in the root directory or