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
6
votes
5 answers
ConstraintViolationException handler isn't executed in Micronaut
I have a ConstraintViolationException handler class that looks like this:
@Produces
@Singleton
@Requires(classes = {ConstraintViolationException.class, ExceptionHandler.class})
public class ConstraintsViolationsExceptionHandler
implements…

Shankha057
- 1,296
- 1
- 20
- 38
6
votes
2 answers
Have Spring respond with 400 (instead of 500) in case of a request header validation error
When using validation for parameters of a Spring MVC @RequestMapping method, Spring responds with with different status codes depending on the type of the parameter:
For invalid @RequestBody parameters, Spring responds with 400
For invalid…

oberlies
- 11,503
- 4
- 63
- 110
6
votes
3 answers
How to log validation errors in Spring boot application
I'm using SpringBoot (spring-boot-starter-web 1.5.16.RELEASE) and hibernate-validator 6.0.11.Final in my REST service.
DTO objects annotated with proper validation constrains (UPDATE: I'm using @Valid annotation on controller's parameter) and…

igor
- 699
- 1
- 9
- 26
6
votes
1 answer
How to use @NotNull with spring boot?
I have this dependency:
org.hibernate.validator
hibernate-validator
Which have it's version managed by
org.springframework.boot
…

rado
- 5,720
- 5
- 29
- 51
6
votes
1 answer
JSR303: Trying to customize a constraint violation to be associated with a sub-path in a class-level relationship constraint validator
I am using JSR303 and created a class-level constraint that compares the password and its confirmation in a form, which I shall name here the @SameAs constraint. Ideally, I would have liked to associate the constraint with the intended target…

KingCode
- 858
- 1
- 9
- 9
6
votes
1 answer
When using @AssertTrue in methods, the method is invoked 4 times during validation (Bean Validation)
When using bean validation to validate the state of an object, the method annotated with @AssertTrue is called 4 times whenever the validation is invoked. It should only be called once per invocation.
Hibernate-validator version: 5.1.3.Final
Here is…

Henrique Fernandes Cipriano
- 555
- 6
- 17
6
votes
2 answers
JSR - 349 bean validation for Spring @RestController with Spring Boot
I am using Spring Boot 1.5.2.RELEASE and not able to incorporate JSR - 349 ( bean validation 1.1 ) for @RequestParam & @PathVariable at method itself.
For POST requests, if method parameter is a Java POJO then annotating that parameter with @Valid…

Sabir Khan
- 9,826
- 7
- 45
- 98
6
votes
1 answer
Hibernate validations on save (insert) only
We encountered a problem with legacy code. There is a validation set for a "username" field, validating its length and making sure it contains at least one letter:
@Column(name = "username")
@Size(min = 4, max = 40)
@Pattern(regexp =…

Tomer A
- 453
- 3
- 14
6
votes
1 answer
JSR 303 ConstraintViolationException and detailed message
I have configured my Spring Boot 1.5.1 application with JSR 303 validation. Right now I'm getting ConstraintViolationException in case of wrong data.
Is it possible to get a detailed message(now it is null) about what was wrong(for example what…

alexanoid
- 24,051
- 54
- 210
- 410
6
votes
3 answers
How to set check order for JSR303 bean validation
I use the JSR303 Bean Validation to check the form input.
@NotBlank
@Size(min = 4, max = 30)
private String name;
@NotBlank
@Size(max = 100)
@Email
private String mail;
when then name = '' and email = '',the @NotBlank, @Size at name, @NotBlank,…

eckelcn
- 61
- 1
- 3
6
votes
2 answers
custom jpa validation in spring boot
I have an entity like this:
@Entity
@Table(name = "transaction_receiver")
public class TransactionReceiver implements Serializable, Addressable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy =…

David Steiman
- 3,055
- 2
- 16
- 22
6
votes
2 answers
Spring MVC (RESTful API): Validating payload dependent on a path variable
Use Case:
let's design a RESTful create operation using POST HTTP verb - creating tickets where creator (assigner) specifies a ticket assignee
we're creating a new "ticket" on following location: /companyId/userId/ticket
we're providing ticket body…

Xorty
- 18,367
- 27
- 104
- 155
6
votes
1 answer
Wildfly: ExceptionMapper not triggered with RestEasy JSR-303 Bean Validation
I'm using Bean Validation with RestEasy in Wildfly 8.2.0.Final:
@Path("/user")
@Produces(MediaType.APPLICATION_JSON)
public class UserEndpoint
{
//more code
@GET
@Path("/encrypt/{email}")
public Response…

Bevor
- 8,396
- 15
- 77
- 141
6
votes
1 answer
Spring JSR-303 bean validation not working, empty bindingresult
Hi StackOverflow
I have tried to add beanvalidation to my small webapplication. Until now it doesn't work because my bindingresult stays empty. I have done the following:
Add all dependencies (Classmate, Javax.el, Jboss-logging,…

Niels Vermeiren
- 238
- 3
- 10