spring-bootspring-mvcthymeleafspring-validation

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:


Solution

  • finally I figured it out to modify my model class (properties) from

    class Translation(
      @NotEmpty(message = "err")
      key: String,
      @NotEmpty(message = "err") 
      en: String
    )
    

    to

    class Translation() {
      @NotEmpty(message = "err")
      key: String = ""
      @NotEmpty(message = "err") 
      en: String = ""
    }