Questions tagged [javax.validation]

105 questions
0
votes
0 answers

Jackson Bean Validation during deserialization of XML using xmlMapper

I've a xml file that I'm deserializing using Jackson XmlMapper. I wanted to do Bean validation during deserialization using javax.validation annotations like @Pattern, @Size, etc. Is there a way to configure Jackson XmlMapper so that I can validates…
0
votes
0 answers

Validation constraints annotation for Map in java

I want to validate the length and pattern of string used in Map, as like String: @Size(max = 45, message = "{validation.name.size.too_long}") @Pattern(regexp = MessageConstants.VALID_REGEXP, message =…
Shashi Ranjan
  • 87
  • 1
  • 10
0
votes
1 answer

Javax validation message according to condition

I have a Spring Boot project in Kotlin which uses a custom locale interceptor to know from which .properties file it load messages. This works pretty fine. Also I have a custom annotation which is simple and has a default message value, as…
Leonardo
  • 1,263
  • 7
  • 20
  • 51
0
votes
0 answers

Groovy javax.validation for each List items with List<@NotBlank String>

Given this object to validate : class GroovyTestListItemValidation { List<@NotBlank String> inner = [] GroovyTestListItemValidation(List elements) { this.inner.addAll(elements) } } Given this (spock) test: class…
Tokazio
  • 516
  • 2
  • 18
0
votes
1 answer

Java Spring Boot Validation

I have a question which is we must use the javax validation as our validator in spring boot? Because I think it is quite troublesome if the business logic becomes more and complicated. And also, there is no order for the validation that make me have…
Jack Noob
  • 47
  • 1
  • 6
0
votes
0 answers

How to resolve error messages in bean validation?

in my application i need to do a bean validation on a loaded (persistent) form element in a http-get method. To do this, i used the following code: DataBinder binder = new DataBinder(formObject); Validator validator =…
0
votes
3 answers

Forcing validation annotation to provide a message

I am using hibernate validator to do POJO validation, and also i have created some custom ones. Here is an example: //lombok annotations public class Address { @NotNull // standard @State //Custom created String country; } We have a…
Adiant
  • 859
  • 4
  • 16
  • 34
0
votes
2 answers

ConcurrentModification exception because of javax.validation exception

I am facing this weird issue where the api is throwing concurrent modification exception because of javax.validation issue. java.util.ConcurrentModificationException: null at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445)…
projectile
  • 61
  • 7
0
votes
1 answer

Use javax.validation outside controller springboot

I'm trying to validate a class outside of the controller using javax.validation and generating an exception of type MethodArgumentNotValidException. I reviewed the following forums, but not so far they have not been helpful: Manually call Spring…
0
votes
1 answer

Invalid form input throws Bad Request without entering springboot controller's method. How to handle?

I have a controller with validated form parameters: @PostMapping("/report") public String reportSubmit(@Valid @ModelAttribute HomeFormInput homeFormInput, Model model, BindingResult bindingResult) { if (bindingResult.hasErrors()) { …
jazzyekim
  • 101
  • 1
  • 10
0
votes
0 answers

Working of javax.validation @NotBlank and lombok @NonNull

I have a simple User class and its properties are annotated with both @NotBland and lombok @NonNull. @AllArgsConstructor @Data @Builder public class User { @NonNull private String name; @NonNull private String id; @NotBlank …
Madu
  • 4,849
  • 9
  • 44
  • 78
0
votes
2 answers

Can I use an autowired variable that's defined in application.yml in javax.validation.constraints.Max?

This is quite a niche question but hopefully someone knows the answer: I have a SpringFramework RestController with a GetMapping, that has some parameter validation using javax.validation annotations. I would like to use a property that's defined in…
Lao
  • 55
  • 1
  • 7
0
votes
1 answer

Javax Validation - Disabling annotation logging for invalid values

I have put a constraint on a field like so: import javax.validation.constraints.Pattern; @Pattern(regexp=SOME_REGEX) private String someField; The regex is working correctly, but in the case of an invalid value, the value is getting logged: [Field…
0
votes
1 answer

Spring service is null in custom ConstraintValidator

I have spring boot project, a bean using javax validation API. I'm trying to inject a service in my custom validator for a bean. But the service object is null. I don't find a complete example that use Spring ConstraintValidator and i don't…
Nozomi
  • 56
  • 4
0
votes
1 answer

Json request validation for mandatory field - springboot rest-api

In below json request, you can see salary is available at 3 level student level, trainee level and properties level employee{ id :"123"; name : "ABC"; salary : 100; college : "abcd.."; Trainees : { id :"101"; name :"XYZ"; salary :50; …
Rubeena
  • 171
  • 1
  • 3
  • 11