'Spring boot validation only working with @valid:
My Spring Boot validation only works if I use the annotation like this (I use Kotlin):
@valid:NotEmpty(message = "Please enter a value")
So for example:
data class RandomDto(
@valid:NotEmpty(message = "Please enter a value")
var randomValue: String
)
If I use this it won't work:
@NotEmpty(message = "Please enter a value")
Why is this? I annotated the controller function parameter with @Valid.
Thanks in advance.
Solution 1:[1]
I think it is a dependency issue. make sure to add the following dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Geeth |
