Hello all, what would be the best approach to add...
# ktor
m
Hello all, what would be the best approach to add validation to data classes that are used as endpoint schemas? Right now I'm using protobuf and creating my own serializers... But that gets out of hand very easily.
m
Can't you use kotlinx.serialization for this?
b
You can use init blocks for runtime integrity validations
m
Kotlinx.serialization is what I'm using but since I'm using protobuf messages instead of data classes to have validation I have to create my own serializers which is really hard to maintain. What I am trying to find is a way to have validation in data classes. Specially if there is a lib for that in a way I don't have to repeat code on every class.
p
What exactly are you trying to validate?
o
Hello @Marcelus Trojahn Could you please shed light on how you use gRPC/Protobuf with KMM's Ktor?
m
Hey there. I am not using for KMM. It's just a Ktor based backend API. If there is anything I can help anyway, let me know.
o
Hey! So you're using Ktor-based backend API on Kotlin Multiplatform, correct?
b
No, he means ktor server which is only available on jvm for now
i.e. not ktor client which is an entirely different thing
o
Ah I'm sorry, I confused Ktor client with Ktor server 🙂
b
No worries, lots of people confuse the two
o
Thanks for your input everyone, for the sake of consistency, I'm going to ask about using KTOR for gRPC/protobuf as a new post on #ktor.