I am working with sprinboot in a simple web application, I using the spring validation framework to validate my fields constraints.
I have a "version" field that its a float, when I enter strings for example my binding result throws this message at the html:
Failed to convert property value of type java.lang.String to required type java.lang.Float for property version; For input string: "StringTemplate"
Ive tried the rejectValue in the controller but it always show first the default message and then my custom one.
Failed to convert property value of type java.lang.String to required type java.lang.Float for property version; For input string: "StringTemplate" Version must be a number
Is there a way to fix this?
Thanks!
A solution could be custom properties. There you can parse your values manually and handle the errors. see https://www.baeldung.com/spring-mvc-custom-property-editor