-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sets the dataPath for the parent #76
Labels
enhancement
New feature or request
Milestone
Comments
@nlochschmidt @sksamuel @jillesvangurp @wtomi Could you please give me some guidance? |
How would you expect this to interact with nested validations? data class Baby(val age: Int)
val babyValidation = Validation<Baby> {
path = Baby::class
Baby::age { exclusiveMaximum(5) }
}
val invalidBaby = Baby(5)
// "Baby.age must be less than 5"
println(babyValidation.validate(notBaby).errors)
data class Parent(val babies: List<Baby>)
val parentValidation = Validation<Parent> { babies onEach { run(babyValidation) } }
val invalidParent = Parent(listOf(invalidBaby))
println(parentValidation.validate(invalidParent).errors)
// ".babies[0].age must be less than 5"
// ".babies[0].Baby.age must be less than 5" |
Likely adding this to 0.9.0 with API: val validation: Validation<Baby> { ... }
val validationWithClass = validation.prependPath(PathSegment.toPathSegment(Baby::class)))
// ".age must be less than 5"
println(validation.validate(notBaby).error)
// "Baby.age must be less than 5"
println(validationWithClass.validate(notBaby).error) |
Fixed by #155, to be released in 0.9.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The current error message is '. age must be less than 5 '.
I add Baby before .age.
e.g: 'Baby. age must be less than 5'
The text was updated successfully, but these errors were encountered: