Interface ConstraintDefinitionContext<A extends Annotation>
- Type Parameters:
A
- The annotation type represented by this context.
- All Superinterfaces:
ConstraintDefinitionTarget
,ConstraintMappingTarget
,TypeTarget
Constraint mapping creational context representing a constraint (i.e. annotation type). Allows to define which
validators should validate this constraint.
- Author:
- Yoann Rodiere
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Allows to specify a validation implementation for the given constraint and data type using a Lambda expression or method reference.static interface
Callable implementing a validation routine. -
Method Summary
Modifier and TypeMethodDescriptionincludeExistingValidators
(boolean includeExistingValidators) Specifies whether validators already mapped to this constraint (i.e. defined in the annotation declaration throughConstraint.validatedBy()
or the validation engine defaults) should be included or not.validatedBy
(Class<? extends ConstraintValidator<A, ?>> validator) Adds a new validator to validate this constraint.validateType
(Class<T> type) Allows to configure a validation implementation using a Lambda expression or method reference.Methods inherited from interface org.hibernate.validator.cfg.context.ConstraintDefinitionTarget
constraintDefinition
Methods inherited from interface org.hibernate.validator.cfg.context.TypeTarget
type
-
Method Details
-
includeExistingValidators
Specifies whether validators already mapped to this constraint (i.e. defined in the annotation declaration throughConstraint.validatedBy()
or the validation engine defaults) should be included or not.- Parameters:
includeExistingValidators
- Whether or not to use already-mapped validators when validating this constraint.- Returns:
- This context for method chaining.
-
validatedBy
Adds a new validator to validate this constraint.- Parameters:
validator
- The validator to add.- Returns:
- This context for method chaining.
-
validateType
@Incubating <T> ConstraintDefinitionContext.ConstraintValidatorDefinitionContext<A,T> validateType(Class<T> type) Allows to configure a validation implementation using a Lambda expression or method reference. Useful for simple validations without the need for accessing constraint properties or customization of error messages etc.- Parameters:
type
- The type of the value to validate- Returns:
- This context for method chaining
-