I am not sure how to look for this info without go...
# spring
t
I am not sure how to look for this info without going through github issues, so maybe someone knows and can save me some time. assuming I have something like
Copy code
class MyRestRepresentation(@get:NotBlank val notBlank: String)
and someone makes an http call like
Copy code
POST { notBlank: null }
kotlin will throw an exception (jackson will actually) before validation happens. this messes up the error response a bit, since with javax validation we get a nice path to the property that fails validation oob, while otherwise we probably need to do it manually, if at all possible. is Spring working on something like doing validation before before or some other approach or is my best option to declare
notBlank
as
String?
and just read it as
notBlank!!
?
k
I would guess that with javax.validation bean has to be first instantiated and then it is being validated
t
that is the current behavior, but maybe given the improved kotlin support spring is adding they are thinking of something 🤷
k
I don't think this is really spring issue, I would ask in general how to handle this javax.validation vs nullability
j
yup this is is probably an issue with hibernate validation project (no relation to hibernate ORM), not spring
t
I think the problem is more that validation happens on the bean, so the bean needs to be created first. and ofc binding a null property into a non null field cause a failure even before any validation is triggered. so after all I was not expecting “good” news 🙂