I am trying to use bean validation in Webflux. This is what I have so far:
@PostMapping("contact")
fun create(@RequestBody @Valid contact: Mono<Contact>) : Mono<Contact> {
return contact.flatMap { contactRepository.save(it) }
.doOnError{ Error("test") }
}
The The validation doesn't work... I would expect that the Error("test")
would be shown...
Does someone has a working example(Java or Kotlin)?
UPDATE
Here is a repository so it can be reproducted: https://github.com/jwz104/webflux-validation-test
Request:
curl --request POST \
--url http://localhost:8080/tickets \
--header 'content-type: application/json' \
--data '{
"email": "",
"name": "",
"message": ""
}'
Renamed contact to ticket, but everything is still the same.
Errors
orBindingResult
argument in your handler method signature? – LumberonErrorXX
and doesn't work for me – Haber