Top Description Inners Methods
org.hibernate.validator.cfg.context

public Interface ConstraintDefinitionContext<A extends java.lang.annotation.Annotation>

extends ConstraintMappingTarget
Known Direct Implementers
org.hibernate.validator.internal.cfg.context.ConstraintDefinitionContextImpl
Type Parameters
<A>
The annotation type represented by this context.
Imports
java.lang.annotation.Annotation, jakarta.validation.ConstraintValidator, org.hibernate.validator.Incubating

Constraint mapping creational context representing a constraint (i.e. annotation type). Allows to define which validators should validate this constraint.
Author
Yoann Rodiere

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ConstraintDefinitionContext.ConstraintValidatorDefinitionContext<A extends Annotation, T>

Allows to specify a validation implementation for the given constraint and data type using a Lambda expression or method reference.

public static interface
ConstraintDefinitionContext.ValidationCallable<T>

Callable implementing a validation routine.

Method Summary

Modifier and TypeMethod and Description
public ConstraintDefinitionContext<A>

Returns:

This context for method chaining.
includeExistingValidators
(boolean
Whether or not to use already-mapped validators when validating this constraint.
includeExistingValidators
)

Specifies whether validators already mapped to this constraint (i.e. defined in the annotation declaration through jakarta.validation.Constraint#validatedBy() or the validation engine defaults) should be included or not.

public ConstraintDefinitionContext<A>

Returns:

This context for method chaining.
validatedBy
(Class<? extends ConstraintValidator<A, ?>>
The validator to add.
validator
)

Adds a new validator to validate this constraint.

public <T> ConstraintDefinitionContext.ConstraintValidatorDefinitionContext<A, T>

Returns:

This context for method chaining
validateType
(Class<T>
The type of the value to validate
type
)

Allows to configure a validation implementation using a Lambda expression or method reference.

Method Detail

includeExistingValidatorsback to summary
public ConstraintDefinitionContext<A> includeExistingValidators(boolean includeExistingValidators)

Specifies whether validators already mapped to this constraint (i.e. defined in the annotation declaration through jakarta.validation.Constraint#validatedBy() or the validation engine defaults) should be included or not.

Parameters
includeExistingValidators:boolean

Whether or not to use already-mapped validators when validating this constraint.

Returns:ConstraintDefinitionContext<A>

This context for method chaining.

validatedByback to summary
public ConstraintDefinitionContext<A> validatedBy(Class<? extends ConstraintValidator<A, ?>> validator)

Adds a new validator to validate this constraint.

Parameters
validator:Class<? extends ConstraintValidator<A, ?>>

The validator to add.

Returns:ConstraintDefinitionContext<A>

This context for method chaining.

validateTypeback to summary
public <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:Class<T>

The type of the value to validate

Returns:ConstraintDefinitionContext.ConstraintValidatorDefinitionContext<A, T>

This context for method chaining

Annotations
@Incubating
org.hibernate.validator.cfg.context back to summary

public Interface ConstraintDefinitionContext.ConstraintValidatorDefinitionContext<A extends java.lang.annotation.Annotation, T>

Known Direct Implementers
org.hibernate.validator.internal.cfg.context.ConstraintDefinitionContextImpl.ConstraintValidatorDefinitionContextImpl
Annotations
@Incubating

Allows to specify a validation implementation for the given constraint and data type using a Lambda expression or method reference.

Method Summary

Modifier and TypeMethod and Description
public ConstraintDefinitionContext<A>
with(ConstraintDefinitionContext.ValidationCallable<T> vc)

Applies the given Lambda expression or referenced method to values to be validated.

Method Detail

withback to summary
public ConstraintDefinitionContext<A> with(ConstraintDefinitionContext.ValidationCallable<T> vc)

Applies the given Lambda expression or referenced method to values to be validated. It is guaranteed that null is never passed to these expressions or methods.

org.hibernate.validator.cfg.context back to summary

public Interface ConstraintDefinitionContext.ValidationCallable<T>

Annotations
@FunctionalInterface
@Incubating

Callable implementing a validation routine. Usually given as method reference or Lambda expression.

Method Summary

Modifier and TypeMethod and Description
public boolean
isValid(T object)

Method Detail

isValidback to summary
public boolean isValid(T object)