https://kotlinlang.org logo
#http4k
Title
# http4k
v

Vojtěch Knyttl

12/10/2020, 5:58 AM
is there a way to use data validation api – it allows to define constraints for OpenApi as well as validating input parameters:
Copy code
data class UpdateRequest(
        @get:Size(min = 0, max = 64)
        val name: String?,
        @get:Size(min = 0, max = 512)
        val bio: String?,
    )
d

dave

12/10/2020, 9:28 AM
not directly. We would always actually encode these rules in a custom type which is validated on construction using something like values4k. https://github.com/fork-handles/forkhandles/tree/trunk/values4k
(and yes, I am also involved with that lib)
v

Vojtěch Knyttl

12/10/2020, 9:28 AM
would this help generating OpenApi doc as well?
hmm, I am afraid this wouldn't be as nice as the validation api
is it a good idea if I create an issue for that? this would be great if it was part of the lensing
d

dave

12/10/2020, 1:30 PM
You can if you like, but it will require someone to PR it in to get it working.. it would require custom annotations and alterations to the FieldLookup and Field/FieldMetadata
v

Vojtěch Knyttl

12/10/2020, 1:45 PM
if you could write a tech spec how to implement it, I could try
d

dave

12/10/2020, 1:47 PM
TBH, it's probably going to be quite complicated. I'm not even sure how to spec if without doing most of the work.. 🙂
v

Vojtěch Knyttl

12/10/2020, 1:47 PM
ok 😕
i will summarize it in an issue hoping that one day...
12 Views