Closed amr closed 1 year ago
Just to be clear. You are asking specifically about validating nullable values like String?
and LocalDate?
correct?
Because non-nullables work, e.g.
val validatePassword = Validation<String> {
minLength(8)
}
I believe it is currently not possible to validate nullable in a nice way. Good catch.
I guess we could do either something like
Validation<String?>.ifPresent {
minLength(8)
}
Or probably better
Validation<String?> {
ifPresent {
minLength(8)
}
}
Yep that's accurate, both suggested versions look great to me
For example, how to create a validation for a
String
orLocalDate
? without having them part of some other objectI was able to achieve by dropping to
addConstraint
:but wasn't unable to utilize
required
,ifPresent
or any of the existing validators (minLength
, ...etc).Is that supported?