Bean Validation, previously commonly called just "JSR-303", is an annotation based validation framework for javabean properties and parameters of arbitrary methods. Hibernate Validator is the reference implementation and the most widely used one.
Questions tagged [bean-validation]
1913 questions
0
votes
2 answers
How can a Spring Boot web app validate a form field that is required conditional on another field?
I have a Spring Boot web app in which fields of my form-backing bean are annotated with Bean Validation annotations (see Baeldung's tutorial or the docs at spring.io). For example, fields on Customer beans might be annotated like…

workerjoe
- 2,421
- 1
- 26
- 49
0
votes
1 answer
bean-validation @Pattern the first digit is '1'
How to use bean-validation @Pattern in the field below to check if the first digit is '1'?
private Long registration;

Liam Park
- 414
- 1
- 9
- 26
0
votes
0 answers
java bean validation fails to run: java.io.NotSerializableException: com.sun.el.ExpressionFactoryImpl
I am running Jakarta Bean Validation 6.1.2 under Apache Flink and running into the included "Caused by: java.io.NotSerializableException: com.sun.el.ExpressionFactoryImpl" error.
Here are the gradle deps:
compile…

James Todd
- 21
- 4
0
votes
1 answer
Bean Validation API in JPA
JPA implementation by default check validation constrains at the following
lifecycle points:
javax.persistence.validation.group.pre-persist
javax.persistence.validation.group.pre-update
javax.persistence.validation.group.pre-remove
In a spring boot…

GionJh
- 2,742
- 2
- 29
- 68
0
votes
0 answers
RestEasy SpringBoot Validation and Dependency injection
We are currently converting from Wildfly to SpringBoot + Resteasy, and the last hurdle we have hit is validation that requires dependency injection.
The solution is using
Spring boot 2.2.5.RELEASE
resteasy-spring-boot-starter…

Torben Pi Jensen
- 850
- 9
- 27
0
votes
1 answer
Does Jersey Extension for Bean Validation supports Bean Validation 2.0 (JSR 380)
I am working with WebSphere Liberty 19.0.0.2 with webProfile-8.0 feature which supports jaxrs-2.1 and beanValidation-2.0. For better support for MutiPart streaming I am using Jersey as JAX-RS implementation instead of liberty's default Apache…

Rakesh Prajapati
- 1,078
- 8
- 17
0
votes
0 answers
JSR-380 - Bean Validation of Nested Object and FieldError ObjectName
I have a very precise request. Imagine I have the following basic model :
@ValidStudent
public class Student {
private String firstName;
private String gender;
private List<@ValidCourse Course> courses;
}
public class Course {
…

Pierre Jones
- 620
- 1
- 11
- 24
0
votes
1 answer
JPA: what does bean validation mean for pre-remove?
JPA: what does bean validation mean for pre-remove?
public class Foo {
@Past
private Date date;
}
When removing entity Foo, if the date is valid (a past date), can the entity Foo be deleted or must not be deleted? When deleting an entity,…

eastwater
- 4,624
- 9
- 49
- 118
0
votes
2 answers
Current datetime shouldnt pass the validation using @Past annotation
I need the @Past to error when the field is set to now. I realize that the now value on the field, and the now value used when the validator is comparing would be slightly different, thus the need to set the tolerance in hibernate validator.
Problem…

Bertie
- 17,277
- 45
- 129
- 182
0
votes
1 answer
Should I nest static or not static interfaces within a parent interface
To create conditionally validated groups with jsr 303 validation, an interface class is passed to the annotation like this:
@NotEmpty (groups={UpdateValue.class})
I have quite a few different interface types that I want to group in a parent…

coder
- 6,111
- 19
- 54
- 73
0
votes
1 answer
Custom Validation over FormDataContentDisposition while uploading image as Multipart form data
I want to validate the file extension of image being uploaded using multipart form data in Jersey.
I have created a custom annotation ImageExtensionValidator:
package io.gupshup.dashboard.annotations;
import static…

Ankit Bansal
- 11
- 3
0
votes
1 answer
IBM Websphere 8.5 bean validation issue in JAX-RS resources
Here is the example of the code that I use:
@Stateless
@Path("/rest")
public class MyResouce{
@POST
@Path("/test")
public Response test(@Valid Test t){
return Response.ok().build();
}
}
public class Test {
@Size(max =…

S. Yemets
- 47
- 5
0
votes
3 answers
Java constraint validation doesn't work for parameters
I want use java bean validation annotations for parameters of my spring services. Consider following service:
public interface MyService {
void methodA();
void methodB(@NotBlank String param)
}
with implementation:
@Validated
public…

Denis Stephanov
- 4,563
- 24
- 78
- 174
0
votes
1 answer
Pattern doesn't give correct result
My problem is that I want use bean validation , so I do on my employee bean:
@Pattern( regexp = "\.+",message="Name is not null") @Size(max=10,message = "Name is verylong")
private String name;
I want to check with pattern if the string…

Doppu
- 433
- 2
- 5
- 14
0
votes
2 answers
Validating with Spring that a Boolean element comes explicitly defined
We got this REST endpoint in which one of the field is mapped to a Boolean (The wrapper class) instance. We are using a Boolean instead of a boolean because design decision, so this is non-negotiable.
This Boolean value is mandatory and it must be…

Neuromante
- 531
- 2
- 12
- 29