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

Marcelus Trojahn

11/08/2021, 11:01 PM
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

martmists

11/08/2021, 11:07 PM
Can't you use kotlinx.serialization for this?
b

Big Chungus

11/09/2021, 12:03 AM
You can use init blocks for runtime integrity validations
m

Marcelus Trojahn

11/09/2021, 12:34 AM
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

Paul Woitaschek

11/09/2021, 8:12 AM
What exactly are you trying to validate?
o

Omar Habash

02/21/2022, 11:20 AM
Hello @Marcelus Trojahn Could you please shed light on how you use gRPC/Protobuf with KMM's Ktor?
m

Marcelus Trojahn

02/21/2022, 12:02 PM
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

Omar Habash

02/21/2022, 12:03 PM
Hey! So you're using Ktor-based backend API on Kotlin Multiplatform, correct?
b

Big Chungus

02/21/2022, 12:04 PM
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

Omar Habash

02/21/2022, 12:05 PM
Ah I'm sorry, I confused Ktor client with Ktor server 🙂
b

Big Chungus

02/21/2022, 12:06 PM
No worries, lots of people confuse the two
o

Omar Habash

02/21/2022, 12:32 PM
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.