bean-validation Questions

3

Solved

I have a bean that has a lot of fields annotated with JSR-303 validation annotations. There is a new requirement now that one of the fields is mandatory, but only in certain conditions. I looked a...
Plasm asked 12/2, 2016 at 8:59

3

Solved

I have a calculator service that gets the operation type, num1 and num2 from the user. I need to validate that the user actually inputs these values and doesn't just leave it blank. @RequestMappi...
Cockatrice asked 7/3, 2017 at 8:53

0

I have a Spring Boot (2.4.0) REST service, using Java 11. The endpoints and objects are generated from an OpenAPI 3.0.3 file using openapi-generator-maven-plugin v5.0.1 In the API there is a GET re...
Playback asked 25/2, 2021 at 16:7

2

Solved

I am puzzled by the javax.validation API. I am writing a simple test to understand it: Sample sample = new Sample(); Set<ConstraintViolation<Sample>> violations = validator.validate(sam...
Whitney asked 23/8, 2012 at 17:13

5

Solved

I have a Spring MVC form for inputting a date, the input gets sent to a Controller and validated via standard Spring MVC validation. Model: public class InvoiceForm { @Future private LocalDate ...

2

Solved

I am developing a Spring Boot based REST API. I am validating the input entities using custom ConstraintValidator annotations. My problem is that I cannot return the ConstraintViolationException me...
Pronouncement asked 15/10, 2019 at 17:36

4

Solved

I'm new to using Java Bean validation (JSR-303/JSR-349/Hibernate Validator), and understand the general concepts. However, I'm not sure how to validate the contents of an composed type vs the type ...
Lanettelaney asked 4/12, 2013 at 19:37

3

I have a list of String in my bean. These strings are email and I would like to validate them. @Email @ElementCollection(fetch = FetchType.LAZY) @OrderColumn private List<String> emails = ne...
Ably asked 28/1, 2016 at 0:41

2

Solved

With Bean Validation 2.0 it is possible to also put constraints on container elements. I cannot get this to work with Kotlin data classes: data class Some(val someMap: Map<String, @Length(max ...
Stockpile asked 28/6, 2018 at 14:14

9

Solved

I want to allow only positive integers for number fields including zero. How can I define this validation using JSR 303 ? I tried @Min(value=0 message = "msg1") - But it allows float val...
Dissever asked 15/2, 2012 at 12:15

10

Solved

In a Spring MVC REST service (json), I have a controller method like this one : @RequestMapping(method = RequestMethod.POST, value = { "/doesntmatter" }) @ResponseBody public List<...> myMe...
Forecastle asked 20/6, 2013 at 7:32

6

Solved

I'm looking to do a little custom validation with JSR-303 javax.validation. I have a field. And If a certain value is entered into this field I want to require that a few other fields are not null...
Bedew asked 14/2, 2012 at 21:30

3

I am validating REST service request/bean in a spring-boot 2.3.1.RELEASE web application. Currently, I am using Hibernate Validator, though I am open to using any other way for validation. Say, I h...
Politico asked 19/7, 2020 at 13:52

2

I would like to know if it is possible to stop execution of other validators while one failed? I have some bean, annotated like this import org.hibernate.validator.constraints.*; /*...*/ @NotBl...
Perri asked 13/3, 2013 at 22:41

3

Solved

I need to validate a field in POJO, it must be min length = 2, ignoring leading and trailing whitespaces class User { @NotBlank @Size(min = 2) private String name; } it not works for " A" Ho...
Isomeric asked 21/3, 2017 at 8:39

2

Solved

I'm trying to get Kotlin working with jsr 303 validation on a spring-data-rest project. Given the following data class declarartion : @Entity data class User( @Id @GeneratedValue(strategy = ...
Persecution asked 7/3, 2016 at 15:37

4

Solved

I have a very simple Spring Boot application that uses Spring-Data-Mongodb All I want to do is set a JSR-303 validation rule that says the object I'm saving must have a username. I read that JSR-3...
Piddock asked 21/3, 2014 at 20:31

1

I'm using Spring Boot 2.0.1 with inclusion of validation-starter (which comes with Hibernate Validation 6.x) and trying to validate a method parameter and return objects in my Spring repository lay...

1

Solved

I'm learning about Hibernate Validation in a Spring Boot app and I have a Rest controller and a POST method. And when I make a request, if a field isn't validated successfully, the client should re...
Talus asked 6/6, 2020 at 8:13

2

Spring supports annotation based validation at the controller level. (1) Is it necessary to do such validations also at the RestTemplate level for responses from REST calls? If the answer is Yes:...

1

Solved

I'm working on a Spring Boot 2 project and I'm trying to introduce Bean validation to it. My beans are getting validated, but there is no any error response returned. I have a POJO annotated like...
Nanceynanchang asked 18/5, 2020 at 9:55

2

Solved

Here's a simple source, stating that this date must be in the past using Bean Validation : @Past private Date transactionDate; Is there any BV annotation for validating that the date must be tod...
Horbal asked 19/3, 2011 at 4:1

2

Solved

I am trying to persist the entity with constraint validation, when invoke persist - there is constraint that thrown and the caller get EjbTransactionRolledbackException... so I try to call the vali...
Stagy asked 25/9, 2010 at 11:45

15

Solved

Is there an implementation of (or third-party implementation for) cross field validation in Hibernate Validator 4.x? If not, what is the cleanest way to implement a cross field validator? As an ex...
Getter asked 29/12, 2009 at 4:33

2

Solved

Although, this question has been answered I'm interested why @Validated is needed for a working cascaded validation of Map<String, @Valid Employee>. Update 2: For some deeper understanding ...
Saporous asked 11/2, 2020 at 11:35

© 2022 - 2024 — McMap. All rights reserved.