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
9
votes
2 answers
Bean-Validation 1.1 in Glassfish 4.0 - CDI Injection not working as intended
According to the Glassfish 4.0 wiki, Glassfish 4.0 should include JSR349 Bean Validation 1.1.: GF4 wiki link
According to the JSR349 spec, CDI Injection should work out of the box: Bean Validation 1.1. CDI Integration
So I changed my pom.xml…

chzbrgla
- 5,158
- 7
- 39
- 56
9
votes
1 answer
"Turn off" bean validation programmatically (javax.validation.constraints)
For example, we have some entity in whitch several fields are validating with annotation @Pattern. This entity is used everywhere in project, but only in one place we need to "turn off" this validation.
Is there some way to do it programmatically or…

Mary Ryllo
- 2,321
- 7
- 34
- 53
9
votes
2 answers
spring-data-jpa bean validation in junit tests
In my recent work I've used spring-data-jpa to take advantage of provided repositories.
When it came to integration tests I am unable to configure (I assume) spring context for testing and as a outcome bean validation doesn't work in my tests.
I am…

pejas
- 273
- 4
- 9
9
votes
2 answers
can @Valid annotation check on fields recursively in spring mvc?
I make a model object with some JSR-303 validator annotation:
public class UserInfoBasicModel implements Serializable{
@NotNull(message="cannot be null")
@NotEmpty(message="cannot be empty")
private String name;
//getter and setter
…

Judking
- 6,111
- 11
- 55
- 84
9
votes
3 answers
How to include Bean Validation constraints in Jackson generated JSON schema
I am using Jersey 1.2 (still using JDK 1.5) and have developed a REST Booking Web Resource and an associated Booking POJO.
I have used Bean Validation to restrict the size/type of the fields e.g.
@NotNull
@Size(message="invalid…

MandyW
- 1,117
- 3
- 14
- 23
9
votes
3 answers
The orders of bean validation default parameters?
I am currently trying to provide a custom validation message using bean validation.
Currently using spring mvc 3.1.1 + apache bean validation.
In my bean, i specify :
@Size(min=1, max=50)
private String title;
And in my messages.properties…

Bertie
- 17,277
- 45
- 129
- 182
8
votes
1 answer
Custom Class Level Constraint for Crossfield validation not called
I am trying to implement a crossfield validation (JSR-303) with a custom annotation on class level. However the isValid method is not called (but the initialize method).
So my question is: Why is the isValid method not being called for this class…

jonnie119
- 421
- 1
- 6
- 16
8
votes
1 answer
JSR 303 Custom constraint Override
i want to put set of standart constraints (like not null alphanumeric string with length from 3 to 240 chars) on the fields (String in this case) and want to know is there a way to override some of this constraint in the model code. Also is this…

Andrey
- 810
- 1
- 9
- 20
8
votes
3 answers
Presence of BindingResult method parameter determines exception thrown?
I have a Spring @RestController that has a POST endpoint defined like this:
@RestController
@Validated
@RequestMapping("/example")
public class Controller {
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity>…

Roddy of the Frozen Peas
- 14,380
- 9
- 49
- 99
8
votes
4 answers
Spring MVC with Hibernate Validator. How to validate property by group?
There are two problems:
1.Sping/MVC use hibernate validater, Custom validater how to show message?
like: Cross field validation with Hibernate Validator (JSR 303)
@FieldMatch.List({
…

hidehai
- 143
- 1
- 7
8
votes
4 answers
Validation for generated JAXB Classes (JSR 303 / Spring)
I Generated domain objects from schema (request & response) using JAXB (maven-jaxb2-plugin)
I would like add validations (notnull /empty) for couple of attributes. I would like to have custom Bean Validation, the application is a REST service, i'm…

sundark
- 81
- 1
- 2
8
votes
5 answers
ConstraintValidator dependency injection leads to ValidationException when being validated at class level
I've encountered an unexpected behaviour when using dependency injection in a ConstraintValidator which is getting evaluated at class level.
Entity class:
@Entity
@ValidDemoEntity
public class DemoEntity {
@Id
@GeneratedValue(strategy =…

Thomas Schmidt
- 1,248
- 2
- 12
- 37
8
votes
1 answer
Cross Field Validation with inline messaging in JSF with JSR 303
What's the best way to invoke class level JSR-303 constraints that do cross field validation from JSF and have the resulting messages get translated to a FacesMessage and be tied to a particular JSF component based on the PropertyPath in the…

ghilton
- 81
- 2
8
votes
1 answer
How to return a custom response pojo when request body fails validations that are defined using Bean Validation/Hibernate Validator?
Is it possible to override the default response POJO of Spring Hibernate validator?
Currently when a validation gets failed then a very big response returned to the client as shown below. But I don't want the client to provide the full error…

Vivek Garg
- 2,115
- 1
- 20
- 17
8
votes
2 answers
Disable not null checks in Kotlin
class User(val name: String)
I know that in constructor will be added this check
Intrinsics.checkParameterIsNotNull(name)
To make sure that name do not store null.
Is there a way to instrument to not generate such checks? Maybe an annotation?
We…

Combo
- 855
- 2
- 11
- 22