xii
11/25/2021, 4:59 PM@AssertTrue
in the data class, but I'm getting an unused function error (🧵 )xii
11/25/2021, 5:01 PM@GetMapping("/test")
fun validTest(@PathVariable params: Params){
foo(params.from, <http://params.to|params.to>)
}
data class Params(val from: Instant, val to: Instant){
@AssertTrue("from should be before to")
fun areDatesValid(): Boolean {
return from.isBefore(to)
}
}
xii
11/25/2021, 5:02 PMJacob
11/25/2021, 7:05 PMxii
11/25/2021, 7:22 PMTom Hermann
11/30/2021, 10:57 PMis
or get
)
I’d also mark your parameter object as @Valid, so validation is applied. You probably already have it, but you also need this dependency to get all the validation goodness:
implementation("org.springframework.boot:spring-boot-starter-validation")
Jacob
12/01/2021, 4:50 PMThe issue is that your @AssertTrue annotation was not on a function that conforms to the JavaBean specThis doesn't sound right. See https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#chapter-method-constraints
Tom Hermann
12/01/2021, 7:58 PM