-
Notifications
You must be signed in to change notification settings - Fork 34
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
Validate receiver object properties to shorten the code #71
Comments
ydanneg
added a commit
to ydanneg/valiktor
that referenced
this issue
Dec 16, 2021
I really want this, because it also help to build complexe validation, as bound properties allow to retrieve value of these said property |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Currently we have to provide references to a class properties to validate like that
validate(this)
?The problem is that we can't currently provide property references like that:
or even like this:
This is due to a limitation of Validator implementation that works only with KProperty1 property types of a Kotlin Reflect package.
When we reference class property Kotlin returns KProperty1 type which is now used in Validator implementation.
When we reference class instance property Kotlin returns KProperty0 type which is not supported by Validator implementation.
Possible solution
Validator could work with both KProperty0 and KProperty1 types (by overloading
validate
functions) that will give us the way to get property from a validation receiver directlySuggested working test:
The text was updated successfully, but these errors were encountered: