I already know how to receive a JSON object and automatically deserialize it into the required format (e.g. with a data class). Also look here: How to receive JSON object in Ktor?
My problem now is that I want to validate the JSON request and return BadRequest if it's not in the desired format, something like that in Django: https://stackoverflow.com/a/44085405/5005715
How can I do that in Ktor/Kotlin? Unfortunately, I couldn't find a solution in the docs. Also, required/optional fields would be nice.