Questions tagged [spring-validation]
42 questions
0
votes
1 answer
How can I custom spring validation message at runtime?
@Data
public class TestData {
private Integer x;
private Integer y;
@AssertTrue
public boolean isValid() {
String message;
if (x > y) {
message = "message1..."; // here
return false;
…

QIAOMO
- 1
0
votes
0 answers
Common place to set custom validators in Spring 5
We are upgrading our Spring version from 4 to 5.
Validations in the Spring 4 application were implemented by overriding MultiActionController's bind() method and setting the list of custom validators based on the bean to validate and the method that…

batty
- 31
- 8
0
votes
0 answers
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 the '@Validated' annotation on the parameter…

Ali
- 1
- 1
0
votes
2 answers
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 in the constructor.
How do I add my custom Spring…

ugabade
- 23
- 4
0
votes
1 answer
Spring Rest Validation ObjectNode data size limit
I have rest controller with token creation call. Here inside ObjectNode I get big json data. The database column is varchar2(4000) nad I want limit this ObjectNode size to 4000 adding validation at controller level. Not sure how to do this?
data…

Pramod
- 69
- 1
- 10
0
votes
1 answer
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=asc
My PageSort entity is as…

Shanka Somasiri
- 581
- 1
- 8
- 30
0
votes
1 answer
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 ProjectPage…

Shanka Somasiri
- 581
- 1
- 8
- 30
0
votes
0 answers
Is this a bug in org.springframework.validation.Errors in ver 3.0.6?
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 TacoOrder tacoOrder)
{
if…

MLNOOB
- 1
- 1
0
votes
1 answer
Spring Boot MVC Thymeleaf Form Validation Problem Kotlin Class
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 dependencies and more
Below my solution:

Michał Sułek
- 278
- 2
- 11
0
votes
2 answers
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 "Invalid country";
String language() default "";
…

Shamil Puthukkot
- 442
- 2
- 17
0
votes
0 answers
Client-side validation on 2 variables
I'm writing a simple calculator EP, here's the form that I'm using
@AllArgsConstructor
@NoArgsConstructor
@Data
public class CalculatorForm {
private double leftArg;
private double rightArg;
private String operation;
…

Stanislav G
- 3
- 1
0
votes
2 answers
Spring Validation seemed to stop working (Logging that all fields are null)
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 field filled out it returns a bad request and logs…

Michael
- 51
- 1
- 12
0
votes
1 answer
Eclipse (Maven) Changes not being compiled/built by auto-reloader
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, and when it does, it appears totally random.…

sponsky
- 31
- 4
0
votes
1 answer
How to override the message in a custom validator when the base code is unique to all the controller implementations
I have written an AbstractCRUDController class and have a getById method as shown below
public abstract class AbstractCRUDController {
…

Shanka Somasiri
- 581
- 1
- 8
- 30
0
votes
1 answer
How to perform a validation on an attribute only if the value of the attribute is not null
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 = "invalid input for id")
private String id;
…

Shanka Somasiri
- 581
- 1
- 8
- 30