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
1 answer
176 views

I have a library that uses javax.validation.constraints and I want to use it with both SpringBoot 2 and SpringBoot 3 apps. The validation needs to happen on startup of the SpringBoot app when it in ...
dlipofsky's user avatar
  • 421
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
1 vote
0 answers
52 views

I have a class PojoB which contains a field code and a field of class PojoA: @Data public class PojoB { @Size(min = 1, max = 5) @NotBlank() @Pattern(regexp = "[0-9]+") ...
ildvzg68472's user avatar
1 vote
1 answer
61 views

Situation I am trying to create a autoconfiguration in which some properties must pass validation only in specific cases. I have a service MyService which requires credentials properties.username and ...
Aisteru Firë's user avatar
1 vote
1 answer
233 views

I'm trying to add validation to a bean so I can verify its state before persisting it. The class for the bean that requires validation is generated by the openapi-generator-maven-plugin plugin from an ...
Arno Turelinckx's user avatar
0 votes
1 answer
560 views

I am using Spring Boot 3 with Hibernate's Jakarta Validation. In my application, I have two groups of validations: Default validations Complex custom customizations that should only run if the ...
Elias Schoof's user avatar
  • 2,074
0 votes
0 answers
51 views

I am kind of new to Spring Validator and came through some educational code like this: @Component("singerValidator") public class SingerValidator implements Validator { @Override public ...
totalfrank's user avatar
0 votes
2 answers
178 views

Why do we see the Spring Beans related to Inbuilt and Custom validators initialized ONLY during the first request. Can this behavior be changed to initialize as part of the application startup in ...
Rayyan's user avatar
  • 173
0 votes
1 answer
158 views

I have a typical Spring Boot (3.3.2) MVC application using validation and thymeleaf (3.1.2.RELEASE), and I'm finding that Thymeleaf seems to disregard the i18n messages specified in the validation ...
Alexander's user avatar
1 vote
0 answers
57 views

For my springboot application / framework, I would like to create a custom Constraint Validator to validate Configuration Properties upon application startup. Based upon a different boolean property, ...
user25911120's user avatar
0 votes
0 answers
43 views

Here I have attached my project codes. I am trying to create a crude operation using input form. I have add a javascript code to add additional forms. Suppose, when I click Add Dependent button in ...
Iqbal Hossain's user avatar
0 votes
0 answers
48 views

Im very new to the SpringBoot framework, currently i'm trying to create a working page for CRUD operations required for my project. The problem is in my controller BindingResult wont catch any errors ...
Elzar's user avatar
  • 11
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
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
0 votes
1 answer
736 views

I'm conducting tests to validate when a field in a request body is not received, and I expect an exception to be thrown. However, Spring doesn't even return the generic error. I've generated classes ...
DarkVaderM's user avatar
0 votes
0 answers
31 views

I have this method: @GetMapping public List<BudgetForecastApi> findByHotel(@PathVariable @Positive final int hotelCode, @RequestParam(value = "includeDeleted", defaultValue = "...
User1's user avatar
  • 127
0 votes
0 answers
628 views

I am trying to add Validation for my request parameters of my rest endpoint. I see that @NotBlank is working as expected and throwing Constraint violation exception while @NotNull is not. import javax....
har123's user avatar
  • 59
7 votes
2 answers
4k views

I am creating Spring boot APIs and one of the API consumening data below: class DataRequest{ @Size(min=1, max=10) private String dataTitle; private List<String> emails; } How can ...
Nitin's user avatar
  • 2,961
0 votes
1 answer
672 views

Total newbie having trouble learning how to modify a spring boot application with a custom validator(maven, h2 repository, thymeleaf, not sure if this info is implied or necessary so here it is). I ...
Lalochezia's user avatar
0 votes
0 answers
25 views

I am upgrading the spring framework from very old version to 5.3.9. In the current Spring configuration, I have below validation framework included. In the new spring, I will not have the below info ...
user3067524'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
1 answer
440 views

I'm utilizing Spring Boot 3 with starter validation / Jakarta Validation via the Controller methods, and @Valid and @Validated annotations, and am using actuator for metrics. There is a lot of "...
TheJeff's user avatar
  • 4,227
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
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
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
3 votes
1 answer
69 views

I want to validate the JSON content of a POST request in my controller. I use @NullValue annotations and a custom Validator for a conditional validation. The input is invalid if the attribute type is ...
Datz's user avatar
  • 4,021
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
-1 votes
1 answer
293 views

I have this custom annotation interface: @Documented @Constraint(validatedBy = NameValidator.class) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface NameValidation { ...
MSmith's user avatar
  • 59
0 votes
1 answer
609 views

I will try to force the user their password must have some constraints. So, I use @Pattern annotation to force user to enter the password according to my constraints. But the problem is i send the ...
Adem Galitekin's user avatar
0 votes
1 answer
524 views

Here is my simple registration controller method for Sensor. @PostMapping("/registration") public ResponseEntity<HttpStatus> create(@RequestBody @Valid SensorDTO sensorDTO, ...
Papahh's user avatar
  • 21
0 votes
1 answer
214 views

I have a problem implementing a user controller in a rest api, spring boot: The problem is the following, it is all configured to receive the json, but when I put the json I have a return, 403 ...
MATEUS DE SOUZA ALVES'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
2 votes
2 answers
2k views

I'm using Spring Boot 2.4. I have the following controller with a method that accepts a MultipartFile object. @RestController public class MyController extends AbstractController ... @Override ...
Dave's user avatar
  • 20.1k
-1 votes
1 answer
604 views

@Data public class Employee{ @NotNull @NotBlank private string id; @NotNull @NotBlank private string name; } @RestController @Validated class EmployeeController{ @postMapping(consumes="json&...
Kannan TK's user avatar
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
0 votes
1 answer
542 views

I have a controller that accepts path parameter called 'jobName'. The @ValidateJobName is the custom validator that validates the user input. If the input is wrong then it throws the error below &...
Sagar SN's user avatar
0 votes
1 answer
3k views

I want to manually call validate(Object target, Errors errors) method from my validator which implements org.springframework.validation.Validator interface. When I bind that validator with @InitBinder ...
GVabal's user avatar
  • 1
0 votes
0 answers
207 views

I have a request DTO, with nested objects as members, and one of them has an @Email validation on it. @AllArgsConstructor @NoArgsConstructor @Getter @EqualsAndHashCode @ToString public class MyRequest ...
Saif's user avatar
  • 3,630
1 vote
3 answers
2k views

I have a spring-boot app in Kotlin. I have a model called MyModel with just two field : a, b NotNull validation works fine on a but it doesn't work on b although I've added @valid on top of b. So when ...
Code_Worm's user avatar
  • 4,510
0 votes
0 answers
343 views

I have a Spring Boot/Webflux project and would like to set a validation error if a username already exists, with a friendly message. However, if I make a non-blocking call to the database in the ...
Shy Albatross's user avatar

1
2 3 4 5
9