https://kotlinlang.org logo
#server
Title
j

Johann Pardanaud

06/22/2023, 12:52 PM
Hi! I am currently working on a new validation library (yet another) and I want to be sure it fits your expectations. I've created a short survey (5 questions only) to gather facts about validation usage inside Kotlin's ecosystem. I would be really grateful if you could take a few minutes of your time to answer and help me with this project. 🙏 https://forms.gle/wfX9cte8GYhpiQTp6
👍🏾 1
👍 4
j

Jilles van Gurp

06/26/2023, 7:58 AM
My hopes/requirements: • No ksp or other compiler hacks. I need less of that in my life not more. • Declarative syntax ala konform is great. we're using that. • Multi-platform is important to us. We put our datamodels in a multi platform library that is used on the web (kotlin-js) and in our spring boot server. We are considering using wasm and compose multiplatform as well. Anything with jvm dependencies is not usable for us.
🙏 1
j

Johann Pardanaud

06/26/2023, 9:19 AM
Thank you to all of you 🙂
@Jilles van Gurp Unfortunately, my library currently involves a small annotation processor, which is required to make the syntax way more readable. However, we could imagine a way for the user to disable the processor and fall back on an API a bit more verbose. Currently, if you have the following models:
Copy code
data class Book(val author: Author)
data class Author(val name: String)
With the KSP processor you can do:
Copy code
Validator<Book> {
    author.name.length {
        between(2, 50)
    }
}
Without it we could imagine a fallback on a Konform-ish syntax:
Copy code
Validator<Book> {
    Book::author + Author::name + String::length {
        between(2, 50)
    }
}