You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please add this in Jakarta EE 11. It is needed by Jakarta Data.
When performing method validation on methods that came from an interface and you don't control the interface yourself, it is currently not possible to request cascading validation on the parameters and return value of the method. The proposal is to support annotating type parameter(s) with @Valid when inheriting from the interface in order to request that cascading validation be automatically performed during method validation for parameters and return values of the annotated type.
For example, Jakarta Data has a built-in interface CrudRepository, which defines a very commonly used save operation, which is where validation of constraints on the passed-in entity parameter is often desired. Jakarta Data repositories that the user defines inherit from this interface, for example,
@Repository
public interface School extends CrudRepository<Student, Integer> {
... // inherits save(Student) operation from CrudRepository
}
@Entity
public class Student {
@Email
public String email;
@NotBlank
public String name;
@Id
public int studentId;
}
The user who defines this class, would like to annotate the Student parameter with @Valid, as follows:
@Repository
public interface School extends CrudRepository<@Valid Student, Integer> {
... // inherits save(Student) operation from CrudRepository
}
which we would like to see cause the constraints of the Student class to be validated when a Student object is supplied to:
I've also observed that constraints on type variables, such as @Positive below, do not seem to have the effect of applying to method parameters of that type, so this pattern might be consistently not working,
@Repository
public interface School extends CrudRepository<@Valid Student, @Positive Integer> {
Optional<Student> findByStudentId(Integer studentId);
... // inherits save(Student) operation from CrudRepository
}
Please add this in Jakarta EE 11. It is needed by Jakarta Data.
When performing method validation on methods that came from an interface and you don't control the interface yourself, it is currently not possible to request cascading validation on the parameters and return value of the method. The proposal is to support annotating type parameter(s) with
@Valid
when inheriting from the interface in order to request that cascading validation be automatically performed during method validation for parameters and return values of the annotated type.For example, Jakarta Data has a built-in interface CrudRepository, which defines a very commonly used save operation, which is where validation of constraints on the passed-in entity parameter is often desired. Jakarta Data repositories that the user defines inherit from this interface, for example,
The user who defines this class, would like to annotate the
Student
parameter with@Valid
, as follows:which we would like to see cause the constraints of the
Student
class to be validated when aStudent
object is supplied to:Mailing list discussion:
https://www.eclipse.org/lists/bean-validation-dev/msg00029.html
The text was updated successfully, but these errors were encountered: