tipsy
09/29/2018, 6:46 PMValidator
class, which can be turned into a TypedValidator
class by calling asInt
, asDouble
, etc: https://github.com/tipsy/javalin/blob/master/src/main/java/io/javalin/validation/Validator.kt
the problem is that i have some duplicated functionality that i'd like to get rid of, but i can't think of any (simple) way of doing thatAndreas Sinz
09/29/2018, 8:24 PMuli
09/29/2018, 8:26 PMtipsy
09/29/2018, 8:38 PMAndreas Sinz
09/29/2018, 9:02 PMT::class.java
be limited to just a couple of types?tipsy
09/29/2018, 10:12 PMuli
09/30/2018, 7:08 AMtipsy
09/30/2018, 8:04 AMasInt()
, asDouble()
etc are the most common types, which is why i've included them by defaultif you need it, can't you define it as fun asInt = asClass<Int>that i can do! thanks
Andreas Sinz
09/30/2018, 12:41 PMasClass<Int>()
and asInt() = asClass(Int::class.java)
? is the latter actually needed?tipsy
09/30/2018, 1:17 PMasInt()
is a lot easier to read and write than asClass(Integer.class)
Andreas Sinz
09/30/2018, 1:40 PMasClass<Int>()
is not much worse than asInt()
tipsy
09/30/2018, 1:41 PMTypedValidator
a base class, i just haven't quite figured out how yetandries.fc
10/17/2018, 7:34 AMasClass<..>()
as extension functions. They are only there as an API, and the core of the functionality is implemented anyway in the fun <T> asClass(clazz: Class<T>): TypedValidator<T>
.