-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
MissingKotlinParameterException should have a reference to KCallable #548
Comments
There didn't seem to be a good reason to implement this in As a side note, |
Not sure I understand you correctly. Do you suggest to create a class just for validation purposes with nullable members? |
Yes, it is. There is no good reason for |
(sry, different account) I completely understand that parsing and bean validation are separate concerns and I didn't ask for bringing the validation concern into this module. I would be happy to help developing a patch on the (whether it would be on the deprecated approach or the new one) if the overall idea is considered ok. |
I have considered it, but still find it difficult to accept this change. As pointed out in #572, In combination with the aforementioned points, the likelihood of incorporating this change as |
One possibility might be to have additional value marked as |
Would work for my scenario. If that would be acceptable, in can try to create a proposal. |
I'll let @k163377 comment; perhaps there are bigger problems wrt feasibility. But I think proposal is fine. If you do propose a PR, it should have a test to ensure JDK serializability (there are existing tests for other Kotlin module entities). |
Considering only the use case described, I don't think this method is appropriate. First, I haven't looked into how to do this, but wouldn't it be appropriate to use the |
Reading through this again, I actually concur with @k163377. Since validation is a general concern, if integrating validation it'd probably make more sense to use exceptions from |
I'm thinking about how such a module would integrate with existing solutions. Thinking of Quarkus and Spring, validation is usually coming afterwards. It might be a nice addition that kicks off all validations on the spot during parsing (and thus maybe also remove the error source of missed |
Yeah one challenge is just that validation generally operates on POJOs, from top to bottom, which sort of expects full databinding results. So works fine as post-processing after Adding a hook to do something immediately after |
Use case
I want to convert a parameter error to a similar response as it would have been thrown when validation would have run and using the error messages of
javax.validation.constraints
. To be specific:I want to write a data class like:
When making the variable nullable, I would get the message translated. With the definition above, it never gets to validation and throws a
MissingKotlinParameterException
instead. I can catch an process this exception, thus accessing the parameter within the exception. Unfortunately, the parameter type's annotation list is empty (probably because the annotation is associated to the field) - which is required for all other validations as well. AndKParameter
does not provide access to the callable (althoughKParameterImpl
has it).So what I want to achieve is:
Describe the solution you'd like
If I can get
I can already proceed.
Describe alternatives you've considered
As a workaround, I will try to fetch the callable of Parameter via reflection. Getting the actual type might not work with other construction types and callable should be available already.
The text was updated successfully, but these errors were encountered: