Cies
06/19/2024, 1:42 PM@Validate
annotation given that Kotlin tries to avoid them (and the reflection based control flows that result from them) over explicit call chains; and (2) is it possible to inspect the validation constrains (in other words: are the validation constrains "just data" so we can write programs that, for instance, add a max-length=X
attribute a HTML form element if there is a maxLength constraint on the field that backs up the form element)?Johann Pardanaud
06/19/2024, 3:26 PMValidator<Book> {
title.isNotEmpty()
}
title
here is not a property of the original Book
class, but an extension property of the Validatable<Book>
class
This extension property is generated by a KSP plugin. KSP is quite limited and needs the annotation to find the class for which the extension properties needs to be generated.
I plan to rewrite this someday to a FIR compiler plugin, which will allows to get rid of the annotation. But this is a huge step 🙂
(2)
Akkurate was built with complex use-cases in mind. To help with this goal, it supports structured programming like conditions and loops.
Due to this conditional approach — determined at runtime — it is not possible to list all the constraints applied to a specific property, because they can change on each run.
However, I plan to support multiplatform, and allow you to run validation on client-side 😉Cies
06/19/2024, 3:28 PM