August Lilleaas
09/16/2024, 10:26 AMAugust Lilleaas
09/16/2024, 10:28 AMdata class CustomerEntity(
val id: String,
val createdAt: LocalDate,
val modifiedAt: LocalDate,
val name: String,
val status: EntityStatus,
val email: String
) {
val patchProps = setOf(::name, ::status, ::email)
}
That way, I can at least refer to the properties I want to be “patchable”. But the type of these properties are relatively weak, and I’m not sure how to somehow apply this set of KProperty instances to an incoming JSON map etchfhbd
09/16/2024, 10:42 AMvar
. Ideally, the generator should support nested classes/usages too ;)August Lilleaas
09/16/2024, 10:43 AMhfhbd
09/16/2024, 10:45 AMhfhbd
09/16/2024, 10:46 AMTóth István Zoltán
09/16/2024, 11:50 AM@Adat
class StringTest(
val someString : String
) {
override fun descriptor() {
properties {
someString minLength 2 maxLength 4 default "1234" blank false pattern "[0-9]*" secret true
}
}
}
I actually have a readonly
descriptor that I use to indicate read-only fields. The compiler plugin turns the descriptor
(and the data fields) into this.
{
"version": 1,
"name": "fun.adaptive.adat.validation.StringTest",
"flags": 1,
"properties": [
{
"name": "someString",
"index": 0,
"flags": 3,
"signature": "T",
"descriptors": [
{
"name": "StringMinLength",
"parameters": "2"
},
{
"name": "StringMaxLength",
"parameters": "4"
},
{
"name": "StringDefault",
"parameters": "1234"
},
{
"name": "StringBlank",
"parameters": "false"
},
{
"name": "StringPattern",
"parameters": "[0-9]*"
},
{
"name": "StringSecret",
"parameters": "true"
}
]
}
]
}
Tóth István Zoltán
09/16/2024, 11:53 AMAugust Lilleaas
09/16/2024, 12:08 PM