Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
33 views

I have object that I want to validate using Spring Validator. public record MyRequest( List<@Valid Item> items, // ... ) and Item: public record Item( String foo, // ... ) Then I want to ...
pixel's user avatar
  • 26.8k
1 vote
1 answer
187 views

I am learning how to effectively use the Spring’s Bean Validator in my REST project. I have the following POJO: public class Project { @NotBlank(message = "%s is mandatory") private ...
zappee's user avatar
  • 23.2k
0 votes
0 answers
48 views

I would like to fail a trace when the validation @Valid of the request payload fails. @Autowired MyService myService; @PostMapping("/validate") String question(@Valid @...
PatPanda's user avatar
  • 5,418
0 votes
0 answers
66 views

I am following a course at my college where we build a simple SpringBoot application. This task is about validation. I handle the data exchange with several DTOs (for creating, updating and response). ...
Oliver R.'s user avatar
1 vote
0 answers
83 views

I would like to use the SpringBoot @Valid to validate a http request field, but based on another field of the same http request. I have the following code: <?xml version="1.0" encoding=&...
PatPanda's user avatar
  • 5,418
0 votes
1 answer
53 views

I would like to write some unit test to test the @Valid of SpringBoot request, hopefully, without having to spin the server. For instance, in the "old way", one could write a piece of code ...
PatPanda's user avatar
  • 5,418
0 votes
1 answer
96 views

I would like to use @Valid from SpringBoot to perform request validation on a particular field. However, I would like the validation on the field to be configurable. I.e, with one configuration, ...
PatPanda's user avatar
  • 5,418
0 votes
1 answer
57 views

My goal is to validate (fail) against a request which looks like this: { "title": "some title", "foos": [null] } I have this straightforward code: import jakarta....
PatPanda's user avatar
  • 5,418
0 votes
2 answers
67 views

I'm using spring data validation and i want to validate Set or List of Date but all the examples that i saw before were validating single value, Here is request class representation ...
Youssef Gamal's user avatar
0 votes
0 answers
44 views

I am working on a Spring Boot project where I want to display validation error messages defined in my DTO directly on the view using Thymeleaf, especially the "content" field. While the ...
Haebin Noh's user avatar
0 votes
1 answer
211 views

I am writing the backend part of an application in which I want to implement the ability to accept and validate for each object in the list. I know about two annotations that can do this: @Valid is ...
BogdanPhoenix's user avatar
1 vote
1 answer
125 views

I created an annotation named OptimizedName to validate the user name and expected it to inherit from @Size, while still allowing the override of the min and max attributes. However, it's not working. ...
Tùng Trần's user avatar
0 votes
0 answers
25 views

I have added validation constraints on fields of class which maps to the input fields of registration form, after invalid input I want to show same form with error message populated with it. I am ...
Shrikant Bochare's user avatar
0 votes
1 answer
677 views

I thought @Valid annotation would enable validation for nested POJO. But it fails with IllegalArgumentException. I have two POJO # EmailAddress.java import jakarta.validation.constraints.Email; ...
xohouo's user avatar
  • 58
2 votes
1 answer
107 views

How to throw an error message when there is no method mapping in Spring controller. In the following example GET /api/v1/foos doesn't exist, is there a way to throw a generic message (say api/v1/foos ...
user352290's user avatar
  • 1,360
0 votes
1 answer
276 views

I am working with sprinboot in a simple web application, I using the spring validation framework to validate my fields constraints. I have a "version" field that its a float, when I enter ...
Joaquinm's user avatar
0 votes
0 answers
310 views

I have a Spring boot 3.1.2 project with a "Document" entity which has a multipartFile field named "documentFile". Im trying to endpoint-side validating it using Constraint ...
Sphirye's user avatar
  • 29
1 vote
0 answers
182 views

I am using Spring boot 3 Rest Api, with spring-validation-starter. Even after configuring Message Source and LocalValidatorFactoryBean, as follows @Bean @Primary public MessageSource ...
Amit Agarwal's user avatar
0 votes
1 answer
432 views

I have a getMapping controller which accepts emailId and Set as input. I want to have a validation check for Non empty/blank values and email id validation, below is the sample code. @Email validation ...
Nithya's user avatar
  • 1
0 votes
0 answers
267 views

I'm trying to implement standard bean validation in our project which is using Spring Webflux with functional endpoints. Spring Boot Version: 2.7.14 Spring Boot Starter Validation: 2.7.14 <...
Rahul's user avatar
  • 717
2 votes
1 answer
75 views

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 ...
b. tsutskiridze's user avatar
1 vote
0 answers
221 views

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 ...
sternbergm's user avatar
1 vote
0 answers
54 views

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 ...
Kabindra Shrestha's user avatar
0 votes
0 answers
414 views

i have this code to deal with ConstraintViolationException to return only the message that in the constrains @ExceptionHandler(ConstraintViolationException.class) @ResponseStatus(BAD_REQUEST) ...
Abdulaziz Alharbi's user avatar
0 votes
0 answers
181 views

I have a controller where I have multiple levels of validation combined. The problem is that the validation on 'ToBeValidated' class are executed. But the '@SystemId' validation is skipped because of ...
Ali's user avatar
  • 1
1 vote
1 answer
1k views

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&...
NqanVo's user avatar
  • 117
0 votes
2 answers
541 views

When working with ConstraintValidators, we just need to define the class and constraint and Spring is able to detect the validators and instantiate them automatically, injecting any beans we ask for ...
ugabade's user avatar
  • 23
3 votes
0 answers
469 views

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( ...
TheJeff's user avatar
  • 4,227
0 votes
1 answer
158 views

I am using Springboot 2.7.9 and I need to invoke a Request as below localhost:8081/api/projects?page=2&size=3&sortBy=projectName&sortDirection=desc&sortBy=startDate&sortDirection=...
Shanka Somasiri's user avatar
0 votes
1 answer
43 views

My PageSort Entity, @Data @AllArgsConstructor @NoArgsConstructor @Builder public class PageSort { private String sortBy; @SortValueConstraint private String sortDirection; } My ...
Shanka Somasiri's user avatar
1 vote
0 answers
41 views

Here's my method for processing the taco, I return to the design view if there's an error found. @PostMapping public String processTaco(@Valid Taco taco, Errors errors, @ModelAttribute ...
MLNOOB's user avatar
  • 11
0 votes
1 answer
165 views

I had a problem with thymeleaf form and jakarta validation @Valid annotation and bindingResult - it didn't worked for me - I had always 0 errors I spent a lot of time reading documentations, changing ...
Michał Sułek's user avatar
1 vote
2 answers
1k views

I am having a custom Validator as follows: @Retention(RetentionPolicy.RUNTIME) @Constraint(validatedBy = CountryValidator.class) public @interface ValidCountry { String message() default "...
Shamil Puthukkot's user avatar
0 votes
2 answers
2k views

So I have an endpoint to register a user, that takes a RegisterDto with validations as RequestBody. I sadly don't know since when the validation stopped working, but at the moment even with every ...
Michael's user avatar
  • 91
0 votes
1 answer
220 views

I have the automatic reload enabled in Eclipse with the Maven project I'm currently working on. I've noticed that changes to the application.properties file almost never trigger an automatic reload, ...
sponsky's user avatar
  • 31
0 votes
1 answer
765 views

I have written an AbstractCRUDController class and have a getById method as shown below public abstract class AbstractCRUDController<ENTITY extends BaseEntity, POSTDTO extends BaseDTO, PATCHDTO ...
Shanka Somasiri's user avatar
0 votes
1 answer
70 views

I have a search criteria for a Project model. A Project can be searched using an id or project name. @Data @Builder public class ProjectSearchCriteria { @IsNumberValidatorConstraint(message = &...
Shanka Somasiri's user avatar
0 votes
2 answers
922 views

I have POST endpoint that creates for example Books, in CreateBookRequest class I have another nested class/record that holds BigDecimal price. I want to secure this endpoint so json's (given below) ...
bmrki's user avatar
  • 601
0 votes
2 answers
1k views

I have a projectDTO which accepts a project name and start date. See below @Data @AllArgsConstructor @NoArgsConstructor public class ProjectDTO { @NotBlank(message = "project name is required&...
Shanka Somasiri's user avatar
1 vote
1 answer
127 views

My Source code: Person.java @Component @Validated @PropertySource(value = "classpath:person.yaml") @Data public class Person { @NotNull(message = "test can't be null") ...
VioletTec's user avatar
0 votes
1 answer
52 views

create.html <!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Title</...
Kifsif's user avatar
  • 3,893
-1 votes
1 answer
159 views

I am trying to validate the list which is passed as a parameter to a controller in spring-boot application. I referred Baeldung doc to perform the same, below is the code snippet which i tried to ...
Nithya's user avatar
  • 1
0 votes
3 answers
8k views

I have one NumberConstraint as follows: @Constraint(validatedBy = { StringConstraintValidator.class, }) @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD, ElementType....
MiGo's user avatar
  • 783
3 votes
0 answers
297 views

I have validations in my application which are built based on spring validation annotations like NotNull, NotEmpty. public class AccountCreateRequest { @NotNull private String accountName; ...
sabu's user avatar
  • 2,107
1 vote
1 answer
360 views

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 ...
Ajay V's user avatar
  • 559
0 votes
0 answers
70 views

I have the following Java class in my project public class Post { public final @Nullable Optional<@Size(min = 10, max = 255) String> title; public Post(@JsonProperty("title") ...
André Lima's user avatar
0 votes
1 answer
4k views

We are using spring custom validator for our request object used in our controller endpoint. We implemented it the same way as how its done in the link below: https://www.baeldung.com/spring-mvc-...
Xmus Jackson Flaxon Waxon's user avatar
5 votes
1 answer
3k views

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....
artak-avanesian's user avatar
1 vote
1 answer
8k views

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: @...
user1999453's user avatar
  • 1,453
1 vote
1 answer
2k views

openapi minimum/maximum put: summary: add operationId: add requestBody: description: value required: true content: application/json: ...
J.J. Beam's user avatar
  • 3,171