bean-validation Questions

5

Solved

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 u...
Lanoralanose asked 2/2, 2017 at 3:29

2

Solved

public class Register { @NotNull private String password; @NotNull private String passwordRepeat; @AssertTrue private boolean comparePasswords() { return password.equals(passwordRepeat); } ...
Jural asked 17/10, 2012 at 13:24

3

In my Spring application that is built with Kotlin I would like to use bean validation on a data class that looks like this. data class CustomerDto( @field: NotBlank val firstName: String, @fi...
Bolivar asked 21/9, 2018 at 13:21

3

Solved

I noticed that all built-in constraints have an empty value for the validatedBy parameter in @Constraint. i.e. @Constraint(validatedBy = {}) First, why are they allowed to have an empty value for ...
Rolf asked 22/12, 2010 at 19:18

5

Solved

I'd like to have a @Unique constraint with Bean Validation, but that is not provided by the standard. If I would use JPA's @UniqueConstraint I wouldn't have a unique validation and error reporting ...
Nonmetallic asked 16/8, 2010 at 16:53

4

Solved

Good Afternoon, I am having problem to inject a service within a Bean Validator (JSR 303). I would be performing a validation, but I need to validate this record in my database; When I use my ser...
Racer asked 12/11, 2012 at 19:52

5

Solved

I'm using JPA 2.0/Hibernate validation to validate my models. I now have a situation where the combination of two fields has to be validated: public class MyModel { public Integer getValue1() { ...
Padre asked 6/5, 2010 at 14:21

3

Solved

I have a Spring @RestController that has a POST endpoint defined like this: @RestController @Validated @RequestMapping("/example") public class Controller { @PostMapping @ResponseStatu...
Gayton asked 21/10, 2021 at 1:58

3

I have a class with validation annotations on my properties, like this one: @NotNull(payload = INVALID_CATEGORY_DESCRIPTION.class) @Size(min = 1, max = 255, payload = INVALID_CATEGORY_DESCRIPTION_...
Dulia asked 31/3, 2016 at 20:56

5

Solved

I have the following code in a Spring controller: @Autowired private javax.validation.Validator validator; @RequestMapping(value = "/submit", method = RequestMethod.POST) public String s...
Tabithatablature asked 15/2, 2013 at 10:57

4

Solved

I'm trying to get the same result as when I use @Valid in object parameter from a Controller. When the object is invalid an exception (MethodArgumentNotValidException) is throw by my ExceptionHandl...
Congener asked 17/3, 2018 at 16:47

2

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 para...
Vostok asked 27/2, 2019 at 12:37

2

Solved

I am using Webflux and will proceed with field verification using bean validation. Trying to respond to field errors using @RestControllerAdvice When specifying a group in the bean validation field...
Beatrizbeattie asked 21/8, 2021 at 11:32

4

Solved

JSR 303 Bean Validation contains out of the box some constrains, but also allow to define custom constrains. I have the feeling that there are a lot of constraints common for a lot of projects tha...
Crenulation asked 12/2, 2013 at 10:40

3

Solved

In my Spring Boot project I have two DTO's which I'm trying to validate, LocationDto and BuildingDto. The LocationDto has a nested object of type BuildingDto. These are my DTO's: LocationDto pub...
Slope asked 1/1, 2019 at 21:51

7

Solved

I'm looking for a way to validate a java.lang.Double field in the Spring command bean for its maximum and minimum values (a value must lie between a given range of values) like, public final class...
Sherrellsherrer asked 18/3, 2013 at 23:40

3

When I am validating bean using @Valid annotation in javax.validation, for some objects I am getting ConstraintViolationException and for some I am getting a MethodArgumentNotValidException. I unde...
Adelaadelaida asked 12/7, 2019 at 16:18

2

Solved

I was checking list of available constraints in javax.validation package and I noticed that there is an annotation @Null which force the field to be null. I do not understand what is point of addin...
Kiefer asked 21/6, 2017 at 18:9

4

I have a collection of strings, now I want to make sure that not only the collection is not empty but also each string in that collection does not contain a blank input. @NotEmpty public List&lt...
Armenian asked 11/11, 2014 at 8:17

3

Solved

Java 8 allows things like: public List<@NonNull String> names; But is there a way to access this annotation in runtime or is it available only to compiler plugins? There's new Method#getA...
Fontanez asked 20/7, 2016 at 16:49

5

I have a ConstraintViolationException handler class that looks like this: @Produces @Singleton @Requires(classes = {ConstraintViolationException.class, ExceptionHandler.class}) public class Const...
Seminal asked 19/6, 2019 at 22:4

3

JDK: 1.8.0_131 Tomcat: 8.0.27.0 Hibernate Validator: 6.0.7.Final + all the dependencies downloaded from: Hibernate Validator 6 @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType....

4

Solved

I need to implement range constraints on Entity data fields: @Entity @Table(name = "T_PAYMENT") public class Payment extends AbstractEntity { //.... //Something like that @Range(minValue = 80...
Subjacent asked 13/6, 2016 at 5:24

1

Solved

I'm using Vaadin 14 with Vaadin CRUD AddOns and it seems that my validation does not work for me. If I open my CRUD view and look at these two fields. They are empty strings e.g null. I'm suppose t...
Spanish asked 12/4, 2021 at 17:6

3

Solved

Say I have a simple POJO like below annotated with Jackson 2.1 and Hibernate Validator 4.3.1 annotations: final public class Person { @JsonProperty("nm") @NotNull final public String name; pu...
Boggs asked 18/9, 2013 at 17:43

© 2022 - 2024 — McMap. All rights reserved.