Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
50 views

Spring Boot Eager Initialize ConstraintValidator Beans

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
  • 147
0 votes
1 answer
42 views

Spring + Thymeleaf + Validation ignoring custom messages on validation annotations and going with their own

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
44 views

How to suppress and log custom spring boot configuration properties constraint validator violation?

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
31 views

Spring MVC multiple input form validation in spring boot application

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
26 views

spring validation: handling validation on services

I'd like to get ``ConstraintViolationException` and transform them into custom bussiness errors into service layer. I mean, my code: @Component @Validated @Slf4j public class DummyService { public ...
Jordi's user avatar
  • 22.7k
0 votes
0 answers
37 views

Binding result does not catch any errors. Why?

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
  • 1
1 vote
1 answer
65 views

I want to create an annotation that inherits from the @Size annotation, but it seems that it's not working

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
196 views

How to validate nested POJO with spring validator

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; ...
Uuganbold Tsegmed's user avatar
0 votes
0 answers
21 views

Spring Form Validation Multiple MessageResources

I'm working on migrating a legacy Struts application to Spring (pray for my poor soul) This application has multiple Message Resource/ ResourceBundles that are module specific (e.g. Scheduling_en_US....
Harley Jackson's user avatar
0 votes
1 answer
194 views

Request field validation not performed

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
112 views

Add ConstraintValidator to DTO from dependency library generated by OpenApi

I have a dependency (API lib) with DTOs and Controller Interfaces generated by openApi. In the micro-service code I add the lib and implement interfaces. Now I want to add custom validation. The usual ...
FingerRoll's user avatar
0 votes
0 answers
31 views

Why do I need to use @Validated in my class to get expected errors with @Positive?

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
472 views

spring boot validation of request parameters - @NotNull is not working

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
  • 49
4 votes
2 answers
2k views

How to put validation on list of String coming from request in spring boot?

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,849
0 votes
1 answer
329 views

Spring Boot Custom Validator Not Found Error: HV000030

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
23 views

Spring framework using validator after upgrade

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
264 views

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) ...
Abdulaziz Alharbi's user avatar
0 votes
1 answer
309 views

Spring Boot Controller Validation Metrics

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
  • 3,961
0 votes
0 answers
117 views

Spring validation on multiple levels

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
275 views

How to register custom Spring validator and have automatic dependency injection?

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
83 views

How to accept multiple Query parameters as a list of objects in Spring validation

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
33 views

Spring validation for Query parameters bound to collections in Controller methods wont fetch the correct values

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

How can I make a Spring Validator to be detected and used automatically?

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
  • 3,679
1 vote
2 answers
958 views

How to pass the value from Pathvariable to a custom Validator in springboot?

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
204 views

Spring custom validation annotation isn't working because of null pointer exception?

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
498 views

@Pattern annotation does not work correctly because it runs when i saving the user to the database it validates the hashed password

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
405 views

Getting null from bindingResult after Spring Validator checks duplicates?

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
189 views

Error when requesting user registration, I can not remove the null error?

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
51 views

Input values were not transmitted to the PostMapping controller

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,741
-1 votes
1 answer
125 views

This annotation is not allowed at this location (@Valid)

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

In SpringBoot, how do I create a custom validator for a MultipartFile parameter?

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
  • 17.9k
-1 votes
1 answer
546 views

Validate Additional parameters in Requestbody for Springboot request and throw 400

@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
6k views

How can I create custom validator on Java List type?

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

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; ...
sabu's user avatar
  • 2,049
0 votes
1 answer
495 views

JUnit5 - Rest API controller having custom spring validator is failing

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
2k views

How to manually use org.springframework.validation.Validator validate() method?

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
186 views

Validation on DTO not working from non-controllers

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,192
1 vote
3 answers
1k views

@NotNull not working on nested object properties in a Kotlin class even though @Valid is added

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,390
0 votes
0 answers
301 views

Is there a Reactive way to Validate Form Fields in Spring WebFlux?

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 votes
1 answer
396 views

@JsonIgnoreProperties does not ignore `springframework.validation.Errors` that are implicit in the @Validateable object

I have an object that is annotated with grails.validation.Validateable and that injects an errors object into whatever it annotates. Then I am trying to deserialize this object with com.fasterxml....
Ev0oD's user avatar
  • 1,791
0 votes
1 answer
994 views

Is it possible to change value when using ConstraintValidator in Spring Boot?

I have a string field that may contain whitespaces at leading and trailing. I want to trim these whitespaces and return trimmed text using ConstraintValidator. If the text is null, I want to return ...
user avatar
0 votes
0 answers
412 views

Spring controller Validation not working on HashSet of Objects

I'm having trouble getting the @Valid annotation to fire in my Spring Controller. Basically I have the following class: import lombok.Getter; import lombok.Setter; import javax.validation.constraints....
MetaCoder's user avatar
  • 468
0 votes
1 answer
3k views

Spring custom validator with dependencies on other fields

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
0 votes
1 answer
268 views

Hibernate Validator: Method constraints not evaluated

I have a simple class, which I'd like to validate: public class Model { @NotNull private String someField; @AssertTrue public boolean methodConstraint() { ... } } This class is ...
László Stahorszki's user avatar
5 votes
2 answers
4k views

@PathVariable validation gives 500 instead of 400

In the Spring Framework validating the request respond with error 400 (Bad Request), specially when validating the request body and the request fields decorated with the javax.validation.constraints.* ...
Hossein Mohammadi's user avatar
2 votes
2 answers
2k views

Spring Boot: repository does not autowire in the custom validator

I have a custom validator that validates data against DB using repository: @Constraint(validatedBy = DataValidator.class) @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @...
Dragon's user avatar
  • 2,471
1 vote
0 answers
117 views

Can't add GraphQL directive on list of types

I have the following code to check the ids given: directive @check( type: AnEntity! ) on INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION enum AnEntity{ FOO, BAR, } input AnEntityInput{ ...
Brian's user avatar
  • 7,612
-1 votes
2 answers
1k views

How to display validation error messages and codes in a Spring WebFlux Rest API

I'm using Spring Web MVC in a Reactive SpringBoot Application, and wrote a custom validator. In case of a validation error, a 400 response code is used, which is fine, but then ...
Shy Albatross's user avatar
3 votes
2 answers
5k views

How can i validate dto of type record in spring framework?

I have an endpoint to create the Seller object.I get the necessary information to create the Seller object from the dto of record type. How can i validate this dto in spring validation? I need to make ...
Emirhan Ay's user avatar
1 vote
1 answer
2k views

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: ...
J.J. Beam's user avatar
  • 2,921

1
2 3 4 5
8