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 -- allow overriding THAT particular bean only
So I need to override a bean provided by a dependency in order to customize some configuration.
Is there any way to allow overriding just for THAT particular name?
I don't want to set
spring.main.allow-bean-definition-overriding=true
That's scary.…

User1291
- 7,664
- 8
- 51
- 108
0
votes
2 answers
Micronaut - How to inject Hibernate validator
I am using the Hibernate validation mechanism in my Micronaut project as the documentation suggests.
Unfortunately, I need to react to validation errors manually and handle the errors with specific exceptions. Thus, I can not use the recommended way…

Florian Hansen
- 746
- 7
- 19
0
votes
1 answer
Validating objects integer property with hibernate validator
I want to validate attribute abc using hibernate validator to check if its null or not.
class A {
@NotNull
private B meta;
}
class B {
@NotNull(message = "missing field")
private int abc;
}
When I try to insert data of my pojo class A without…

Freephone Panwal
- 1,547
- 4
- 21
- 39
0
votes
1 answer
JSR-303 with Spring and Hibernate mixed error messages
What I would like to do is have a standard error message that uses an annotation to fill in a value on the said error message. The code should help explain.
I have a model POJO that has fields on it with JSR-303 annotations as such:
@Min(value =…

Andy
- 8,749
- 5
- 34
- 59
0
votes
1 answer
How to bind an error to a field from within a thymeleaf page
I have a simple 'user registration' page with a 'username' field along with other fields. My requirement is 'username' should not be duplicate, for this I have written a ajax function which checks if username is duplicate and if it is duplicate it…

Phoenix
- 11
- 2
- 9
0
votes
0 answers
How to display error message from custom validation on thymeleaf page
Similar question is posted here-> Spring + Thymeleaf custom validation display but I could not figure out the solution so posting this new question.
I have a simple registration form having username,email, password and confirmPassword fields
0
votes
2 answers
javax.validator with spring component
I use javax.validation with Spring. In my test (groovy) I explicitly create validator.
import javax.validation.Validation
import javax.validation.Validator
import javax.validation.ValidatorFactory
ValidatorFactory factory =…

Yan Khonski
- 12,225
- 15
- 76
- 114
0
votes
1 answer
How can I validate primitive array elements?
I just found that @Size also works with primitive arrays.
@Size(...) int[] A
Is there any way to validate each element in A?
Will following blend?
@Size(...) @Min(1) @Max(10) int[] A

Jin Kwon
- 20,295
- 14
- 115
- 184
0
votes
1 answer
@Autowired field is null
Autowiring works everywhere in application except inside this custom validation annotation class where it is null when called from inside isValid() method.
javax.validation:validation-api: 2.0.1.Final
org.hibernate:hibernate-validator:…

Jamie White
- 1,560
- 3
- 22
- 48
0
votes
1 answer
Is there a way to reuse in place validation of Hibernate's implementation of Bean Validation at runtime?
For example, I have got a class:
@Getter
@Setter
class Notification {
private String recipient;
private Channel channel;
enum Channel {
SMS, EMAIL
}
}
I could define my own Validator, for…

MarkHuntDev
- 181
- 3
- 21
0
votes
2 answers
JSR-303 doesn't support such a scenario?
I try to validate beans by Hibernate Validator. It should be programable and based on a JSON config file.
data models:
class A {
field,
other fields
}
class B {
class A a,
other fields
}
class C {
class A a,
other…

Wesley
- 1
0
votes
2 answers
Getting ConstraintViolationException when trying to use BindingResult in Spring Controller
I have and endpoint, where I validate received json document which contains collections of objects. I would like to only log these objects which don't pass a validation, when others i would like to store in db. Controller should return 200 OK in…

Artur Skrzydło
- 1,135
- 18
- 37
0
votes
1 answer
Reuse artifacts from validation
Lets say I create a validator for NewUserRequestBean called @CheckUsernameAvailable.
The validator would perform something simple like
public boolean isValid(NewUserRequestBean request, ConstraintValidationContext context) {
String userName =…

Lordbalmon
- 1,634
- 1
- 14
- 31
0
votes
0 answers
Why does @DecimalMin produce a ConstraintViolationException?
I have a JPA model class, which worked as I expected it. A few weeks ago it started throwing errors and failed to persist.
javax.persistence.RollbackException:
javax.validation.ConstraintViolationException:
One or more Bean Validation…

tgr
- 3,557
- 4
- 33
- 63
0
votes
0 answers
Java Validation API in sub-projects
I couldn't find anything that helped so im asking:
I have two projects. Project A is the base project that defines basic stuff. Project B is a sub-project of Project A and extends its functionality (Project A should work like a framework and there…

Reborok
- 25
- 6