I have a RestController with one endpoint. That endpoint accepts object of data class. Data class has 2 attributes. How do I make sure these attributes are validated?
My data class:
data class FormObject(val email: String, val age: Int)
And controller:
@PostMapping("submit")
fun submit(@RequestBody formObject: FormObject): FormObject {
return formObject
}
How do I make sure email is email and age is not bigger than 150? Thanks,