TheJeff
TheJeff

Reputation: 4101

Jakarta / Spring Validation of Contained Values in Kotlin

I'm running into an issue validating values via a Spring Boot 3 REST API.

More specifically, I need to validate the contained values within a List Param.

Here's my API:

@GetMapping
fun getHelloWorld(
    @Valid queryParams: HelloWorldQueryParams,
): ResponseEntity<HelloWorldResponse> = with(queryParams) { ...

Here is my queryparam class:

@Validated
data class HelloWorldQueryParams(
    @field:Positive val hwId: Long,     // works!
    val hwIds: List<@Positive Long,>?,  // doesn't work :(
)

As you can see above:

What I've tried:

Thanks for any help getting a vanilla solution to this! Would be nice to not have to write my own validator, but any input on why this doesn't work, what's available (or not), or any history for this feature with kotlin and the validation libraries would be very much appreciated!

Upvotes: 3

Views: 420

Answers (0)

Related Questions