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
1 answer
Spring boot 2 rest validator called twice when groups are used
When I enable the @Validated spring annotation at class level in a Rest controller, 2 validation contexts are generated (each one with a different prefix). The @Validated annotation is required as I want to use 2 different validation groups but as…

Hernán Tenjo
- 179
- 2
- 12
0
votes
1 answer
Constraint validator to validate a field in Child class based on another field in Parent class
I have 2 Domain classes like ParentClass and ChildClass.
(ParentClass contains a list of Child class objects in Array list.)
I created separate Validator classes for ParentClass and ChildClass to do the custom validations.
Example validator class…

firstpostcommenter
- 2,328
- 4
- 30
- 59
0
votes
2 answers
Not getting JSR303 annotations to work with Tomcat 7
After a couple hours of Google and a couple of tutorials I'm beat...
It's not the fact that I'm getting errors that can give me hints on what the problem is, it's the complete lack of them that's driving me mad!
The following code works, just not as…

David
- 180
- 3
- 14
0
votes
1 answer
JSR303 validator message recursive resolution?
I have written a JSR303 validator that compares property value to constraint:
@Documented
@Constraint(validatedBy = Cmp.LongCmpValidator.class)
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
public @interface…

Andrey
- 333
- 3
- 5
- 16
0
votes
1 answer
Spring annotation method purpose
I write simple validation annotation for spring project. Problem is that I don't understand some method purpose.
Here is my annotation:
@Constraint(validatedBy = PostCodeValidator.class)
@Target({ElementType.METHOD,…
user10934825
0
votes
2 answers
How can I to pass on additional parameters in validator for fields?
I have validation that email is unique. It's work during registration. But when I try to change email in user profile I have an error.
I check email to run userRepository.findByEmail. If the user was found then email isn't unique. But when the user…

Alexander Lopatin
- 560
- 6
- 18
0
votes
1 answer
How can @Validated work on common method?
In Springboot project, when I try to add @Validated on controller method, it worked.But now I want to add it on a common method, then failed.
Try to add @Validated on controller method, it worked
public class TaskValidator {
private static final…

何子洋
- 47
- 6
0
votes
1 answer
In JPA, why do pre-remove events do not trigger validation unless enabled via validation group property?
JPA delegates validation to the Bean Validation implementation during pre-persist and pre-update entity life-cycle events. But, pre-remove events do not trigger validation unless enabled via validation group property in persistence.xml. Why?

user1418717
- 425
- 2
- 5
- 13
0
votes
1 answer
Spring MockMVC for Post Request and Bean Validation
i have a common problem to test Post-Request with Bean Validation.
Requirements: ContentType is APPLICATION_FORM_URLENCODED and NOT JSON
Model under test:
public class Message extends Auditable{
@Id
private long id;
private String…

Roma Kap
- 517
- 1
- 8
- 23
0
votes
1 answer
How can I validate an unbounded wildcards elements?
I'm writing a code with spring-boot-starter-web:2.1.6.RELEASE which transitively depends on hibernate-validator:6.0.17.
And I got following error.
java.lang.IllegalArgumentException: HV000116:
type is not a reference type: ? extends…

Jin Kwon
- 20,295
- 14
- 115
- 184
0
votes
1 answer
How to avoid a List in entity containing element before save but failing at persist time?
I need to allow users to edit orders which include adding new order items and sub-items under those order items. I have modeled three entities accordingly, Order, OrderItems and OrderSubItems. Each OrderItem must have one or more OrderSubItems…

James
- 2,876
- 18
- 72
- 116
0
votes
0 answers
Proper way to get errors of Bean Validation and show the corresponding messages to the user
I am working in a project using JPA, and Bean Validation. I want to show friendly messages to the user about the validations that failed, and I need to show these messages in different languages based on the Locale of the users.
I am using standard…

Jucaalpa
- 310
- 1
- 4
- 15
0
votes
1 answer
Is there a way to get a variable in to a custom ConstraintValidator when using JAX-RS?
When de-serializing a JSON payload i want to validate a phone number using a custom validator. This validator needs to know what country the customer is in to correctly parse the phone number. The country i can find in the http header…

user2299548
- 85
- 5
0
votes
1 answer
Form Data Is Not Getting Validated Even If ExceptionHandler Is Defied
I'm implementing validation logic to the application. I have declared a class for custom validation logic. My class extends ResponseEntityExceptionHandler and overrides one method (handleMethodArgumentNotValid) to support @Valid and validate form…

amcozmo
- 27
- 5
0
votes
1 answer
How to Use @NotNull Annotation Correctly?
I have used @NotNull annotation on Java bean class for JSF in register page. But it is not working as expceted.
Here is my xhtml page part :
User Name :
And here is my Java bean part :
@NotNull(message =…

berkancetin
- 315
- 1
- 3
- 18