0

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.

KittyCat
  • 415
  • 4
  • 9
  • 26

1 Answers1

0

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>
Geeth
  • 541
  • 3
  • 12