Regarding the request validation : https://ktor.io/docs/request-validation.html#validation-exception, how does it work when I’ll have a ton of routes, can I apply the validation to specific routes or even to a single route ? According to the doc, I should do :
Copy code
install(RequestValidation) {
validate<Post> { post ->
if (post.title.length < 4)
ValidationResult.Invalid("A post ID should be greater than 0")
else ValidationResult.Valid
}
...
But eventually there will be a lot of validations in there. It would be nice if I could apply to my post routes, only the validation regarding the posts…
a
Aleksei Tirman [JB]
03/27/2023, 9:25 AM
You can install the
RequestValidation
plugin into specific routes to apply a validation logic only to them.