You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if a firstName was passed to a Person and this firstName is present then the user should also enter a familyName to pass the validation
if the firstName was not passed (null) then the validation for the familyName should not be active
Something like this should be possible:
data class Person(val name: String?, val familyName: String?)
val validator = Validation<Person> {
Person::name ifPresent {
minLength(1)
Person::familyName {
minLength(1)
}
}
Person::familyName ifPresent {
minLength(1)
Person::name {
minLength(1)
}
}
}
The text was updated successfully, but these errors were encountered:
On a similar note to this, is it possible to somehow infer that a nullable property is non-null if declared as required in the validation spec?
data classUserProfile(
valfullName:String,
valage:Int?
)
val validateUser =Validation<UserProfile> {
UserProfile::fullName {
minLength(2)
maxLength(100)
}
UserProfile::age required {
minimum(0)
maximum(150)
}
}
val user =UserProfile("username", 1)
val validationResult = validateUser.validate(user)
when (validationResult) {
isValid-> {
// validationResult.value.age is inferred to type "Int" instead of "Int?"
}
}
Example:
if a firstName was passed to a Person and this firstName is present then the user should also enter a familyName to pass the validation
if the firstName was not passed (null) then the validation for the familyName should not be active
Something like this should be possible:
The text was updated successfully, but these errors were encountered: