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

Johann Pardanaud

11/11/2023, 6:03 PM
The first tutorial is finally available! Discover how to do server-side validation with Akkurate 🎯 and Ktor ktor Let me know what you think about it. 🙇‍♂️ Is it too long? Too complex? Or is it missing some things? I want to know 🙂
👍 2
👍🏾 1
👍🏼 1
p

PoisonedYouth

11/11/2023, 7:02 PM
The tutorial is really understandable and also suitable for beginners with Ktor. I will also implement the code examples and give you feedback as soon as I'm finished.
🙏 1
🙏🏾 1
d

dave08

11/12/2023, 10:50 AM
Nice example! Little comment:
Copy code
suspend fun findByIsbn(isbn: String): Book? = dbQuery {
    Books.select { Books.isbn eq isbn }
        .map { it.toBook() }
        .singleOrNull()
}
is pretty wasteful for checking if a record exists... usually a select 1 from ... where ... is enough, in your case you retrieve the whole book, and go through mapping code twice, just to check that it's not null...
👍 2
p

PoisonedYouth

11/12/2023, 1:02 PM
I think it will be good to link the final version of the resulting application from the tutorial at the end of the tutorial.
d

dave08

11/12/2023, 1:06 PM
Also, making publicity for DIs that can crash at run-time... it might be nice to include kotlin-inject or dagger with Anvil if you're already giving advice on DIs... they both catch missing declarations at compile time.
And have an import for
ValidationResult
so that the
when
can look cleaner... (or have a
fold(isSuccess ..., is...)
, arrow-style...). It looks just a bit too verbose for those that'll be writing a bunch of them...
j

Johann Pardanaud

11/12/2023, 9:32 PM
@dave08 You’re right, I will simplify the DAO! The issue with the import for ValidationResult is that Ktor is using the same name too. By using the FQCN I was expecting to avoid any misunderstanding for the reader. About DIs, I just wanted to direct the readers to the most popular DIs, so they can learn more if they want.
@PoisonedYouth you’re right, I will!