Closed nlochschmidt closed 2 years ago
Turns out this is pretty difficult to achieve because the return value of the get
function needs to take the type parameter of the provided Property into account and also whether that Property references a Nullable, Iterable, Map or Array, etc...
As a workaround for version v0.1 I have decided to allow the extraction of sub validations while constructing the validations instead of afterwards. This is implemented in 0af7d76f. An example looks like this:
val ageCheck = Validation<UserProfile> {
UserProfile::age required {
minimum(18)
}
}
val validateUser = Validation<UserProfile> {
UserProfile::fullName {
minLength(2)
maxLength(100)
}
run(ageCheck)
}
Related to #37
Unfortunately I haven't found a good way to do this in Kotlin.
It should be possible to access subvalidations of a complete validation for example to use it on input fields.
Probably something along the lines of