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
10
votes
4 answers
javax.validation.NotBlank missing validator
I have requirement that in common api module(multi module project) I can't use any kind of hibernate's validation annotations, so I did use one from javax.validation which is acceptable.
Problem starts when I want to validate my domain objects(I…

daredesm
- 597
- 2
- 7
- 22
10
votes
3 answers
Is there a standard way to enable JSR 303 Bean Validation using annotated method arguments
I've been looking a around for a while now with no luck. I'n not using Spring MVC but still want to use @javax.validation.Valid to enable validation of method arguments. To give an example
public class EventServiceImpl implements IEventService {
…

sfussenegger
- 35,575
- 15
- 95
- 119
10
votes
3 answers
What is the best way to validate request in a Spring Webflux functional application
In a traditional web application it is easy to validate the request body in the controller method, eg.
ResponseEntity create(@Valid @ResponseBody Post post) {
}
If it is a MVC application, we can gather the errors by injecting a BindingResult,…

Hantsy
- 8,006
- 7
- 64
- 109
10
votes
5 answers
Method Parameter Validation with JSR-303
Is JSR-303 also intended for method parameter validation?
If so, is there any example on the web? The biggest challenge I'm facing is how to get a validator within each method. With Spring 3, doesn't it mean that I'd have to inject virtually every…

Tom Tucker
- 11,676
- 22
- 89
- 130
10
votes
5 answers
Is NotNull needed on Kotlin?
I have a class:
class User(
var name: String
)
And a mapped post request:
@PostMapping("/user")
fun test(@Valid @RequestBody user: User) {
//...
}
What if a client will send a JSON of a user with name: null? Will it be rejected by the…

Boris
- 4,944
- 7
- 36
- 69
10
votes
1 answer
Will JAX-RS support validation groups?
From JSR-339:
For simplicity, JAX-RS implementations are NOT REQUIRED to support processing groups other than Default.
This severely limits usefulness of validation in JAX-RS because for example for create and update you are usually using the same…

mmm
- 1,688
- 16
- 35
10
votes
1 answer
Java String Date Validation Using Hibernate API
I am attempting to validate String Date using javax.validation & Hibernate validation. i need to check given String date should be past and it should be correct yyyyMMdd format with all constraints like leap year, 30th, 31st day.
public class…

deadend
- 1,286
- 6
- 31
- 52
10
votes
1 answer
Why @AssertTrue doesn't work while @NotNull works?
I'm working on a entity library. I put some bean-validation annotations on my Entities.
I strongly believe a bean-validation implementation in on the class path.
@javax.validation.constraints.NotNull works and…

Jin Kwon
- 20,295
- 14
- 115
- 184
10
votes
1 answer
Java Bean Validation: How do I specify multiple validation constraints of the same type but with different groups?
I have multiple processes in which the bean properties must have different values. Example:
@Min( value=0, groups=ProcessA.class )
@Min( value=20, groups=ProcessB.class )
private int temperature;
Unfortunately the bean validation JSR 303 has not…

Jemolah
- 1,962
- 3
- 24
- 41
10
votes
3 answers
How to localize Bean Validation messages
I have a class and using annotation to validate the class properties.
My web page (jsf2.2/primefaces/maven) is multilanguage (DE-utch, FR-rench, IT-alian).
My problem is that the hibernate-validator has support for some languages(de, en, es, fr,…

oikonomopo
- 4,025
- 7
- 44
- 73
10
votes
3 answers
Bean Validation Message with dynamic parameter
I am getting started with bean validation, and I'm trying to compose a constraint. My constraint is to validate a CPF(personal document in Brazil). My constraint is working, but I need the message to contain a dynamic parameter.
I'm using…

Henrique Droog
- 313
- 1
- 2
- 13
10
votes
1 answer
Bean Validation Fails on Hibernate Proxy? Expected Behavior?
Im using
hibernate-core-4.0.1.Final
hibernate-validator-4.2.0.Final
I have a lazy loadable Entity
@NotNull
@OneToOne(fetch = FetchType.LAZY,optional = false,cascade = CascadeType.PERSIST)
@JoinColumn(name="library_id")
private Library…

Marvin
- 226
- 1
- 9
10
votes
1 answer
Hibernate not following JPA specifications when combined with Bean Validation API?
This question is a follow up to this one : JPA ConstraintViolation vs Rollback
I did some test about combination of JPA and validation API (JSR-303).
I found the following in JPA specifications (page 101-102):
By default, the default Bean…

ben75
- 29,217
- 10
- 88
- 134
10
votes
2 answers
Localization with bean validation in JSF
I made a MVC based website using JSF 2.0 and RichFaces 4. Every input text validation is been done using bean validation annotations. I am using Hibernate Validator as bean validation implementation.
How can I display a localized message?
If I…

Heetola
- 5,791
- 7
- 30
- 45
9
votes
1 answer
Programmatic Bean Validation (JSR 303) without Annotation
Possible Duplicate:
using Hibernate Validator without calling annotation.
I have this composite constraint annotation (only for illustration):
@Target... @Retention...
@Constraint(validatedBy = {})
@Pattern(regexp =…

Ralph
- 118,862
- 56
- 287
- 383