Questions tagged [spring-validation]

42 questions
4
votes
1 answer

Kotlin spring boot @RequestBody validation is not triggered

I have a problem on a project with validating @RequestBody by using implementation("org.springframework.boot:spring-boot-starter-validation") My DTO looks like this: import javax.validation.constraints.Email import…
3
votes
0 answers

Custom validation without annotation in spring

I have validations in my application which are built based on spring validation annotations like NotNull, NotEmpty. public class AccountCreateRequest { @NotNull private String accountName; @NotNull @Size(max =…
2
votes
1 answer

Cannot use repository inside custom request class for request validations in spring boot

So I am trying to validate email and name in UserCreateRequest class but @Wired doesn't work and userRepository is null UserCreateRequest.java: @Getter @Setter @Component public class UserCreateRequest { private UserRepository userRepository; …
2
votes
0 answers

Jakarta / Spring Validation of Contained Values in Kotlin

I'm running into an issue validating values via a Spring Boot 3 REST API. More specifically, I need to validate the contained values within a List Param. Here's my API: @GetMapping fun getHelloWorld( @Valid queryParams: HelloWorldQueryParams, ):…
TheJeff
  • 3,665
  • 34
  • 52
1
vote
0 answers

Ordering Spring validations using groups and exceptions

I have a controller with a post method that takes in some headers as string as well as a request body as an object. I want to use spring validation for all of it. I currently have my headers validation inline, and my request object has validation…
1
vote
0 answers

Validating RequestParam with multiple annotations

I have only one request param in the rest controller in spring boot 3. I have added @NotBlank and @Size annotations for the validation of that one request param. While validation both annotations are validate and provide exception with both message…
Kabindra Shrestha
  • 333
  • 2
  • 6
  • 17
1
vote
1 answer

Why @NotBlank not violated when leading/trailing space

This is my validation code for a field title: @NotNull(message = "Not null") @NotBlank(message = "Not blank") @Size(min = 10, max = 300, message = "min 10, max 300 characters") private String title; Other validations like the presented @NotNull or…
NqanVo
  • 21
  • 2
1
vote
1 answer

Why SpringBoot validation not work with single @PropertySource

My Source code: Person.java @Component @Validated @PropertySource(value = "classpath:person.yaml") @Data public class Person { @NotNull(message = "test can't be null") private String test; @Value("${name}") private String name; …
VioletTec
  • 71
  • 5
1
vote
1 answer

Network calls inside custom validations in spring boot

I need to validate a number of fields in my REST Api. Is there a specific pattern to do this ? My api is cluttered with these validation calls. Check auth token in the http request against another service to verify access permissions. Validate a…
1
vote
1 answer

Spring boot rest requestbody and @valid not working when object is null/empty

I am trying to apply not null validation on an attribute of my request which is instructedAmount but it is not working. I have a Spring Boot (V2.3.0.RELEASE) application with the following endpoints: @Validated public class TestController…
user1999453
  • 1,297
  • 4
  • 29
  • 65
1
vote
1 answer

openapi generates minimum and maximum which is not working properly

openapi minimum/maximum put: summary: add operationId: add requestBody: description: value required: true content: application/json: schema: $ref:…
1
vote
1 answer

How to fix 'java.lang.NoClassDefFoundError: org/springframework/validation/annotation/ValidationAnnotationUtils' In Spring MVC

I have Spring MVC application with JSP and the server is Tomcat. when I run this web application. Tomcat log as follows. 24-Feb-2022 16:13:16.054 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service()…
0
votes
0 answers

How to get the Only the message form ConstraintViolationException

i have this code to deal with ConstraintViolationException to return only the message that in the constrains @ExceptionHandler(ConstraintViolationException.class) @ResponseStatus(BAD_REQUEST) @ResponseBody public final…
0
votes
0 answers

Failed to read schema document 'xsd', because 'zip' access is not allowed due to restriction set by the accessExternalSchema property

I have upgraded my ant build project from Java 6 to Java 8, Weblogic 10 to weblogic 12c and from spring 3 to Spring 5. When i try to build my project it gives me the error, "**[xjc] [ERROR] schema_reference: Failed to read schema document…
Mounika
  • 1
  • 2
0
votes
0 answers

Axios "POST" request acting differently than Postman when receiving validation error from backend

I am experiencing an issue when trying to receive Spring validation from my back end to the front end. I have the back end validation set up and when testing in postman I receive the correct messages for each field, that I am validating. Here is an…
Borislav
  • 1
  • 3
1
2 3