https://kotlinlang.org logo
#ktor
Title
# ktor
a

Antoni Zwolski

02/27/2024, 12:48 PM
I have a Ktor project, which is divided into features. Let's say that each feature has 4 layers: presentation, domain, infrastructure, and application. How and where should I perform validations? Should I use a validation framework like Valiktor? Should I use Ktor request validation? Or should my DTOs contain value classes that handle the validation? Or maybe it would be better to manually create some validation classes? This is the flow: 1. In routes, I retrieve OfferDto. Then I am calling a Use Case, (here I should check if the DTO is correct). 2. In a use case, I am mapping DTO to Model (here I need to check if this data is correct with my business rule, for example, if this offer is a weapon, I need to check it here and not allow it to be posted, and I also need to perform other validations, like checking if the user has rights to edit this offer, etc.). 3. The service/use-case uses repository data to retrieve or save data. I am a bit lost, how to not overcomplicate it? I would like to keep it clean, and simple.
👀 1
bump