Can anyone help explain why my validation isn't wo...
# spring
i
Can anyone help explain why my validation isn't working?
Copy code
data class Credential(
        @field:JsonProperty("country_code")
        @field:Pattern(regexp = "^[A-Z]{2}$", message = "country_code must be a string of 2 capital letters i.e. DE")
        val countryCode: String? = null,
)
With
Copy code
fun registerCredentials(@Validated @RequestBody credential: Credential):Credential{ 
   //...
}
I've tried
@Valid
and that doesn't work either. I don't get any error, I just ged a object with null values.
t
i
Thanks for the response. I added that and it didn't work. I then added
spring-boot-starter-validation
and I now get validation errors 😄
👍 1