My Spring Boot Application has an API - GET : /employee
And request can have query params like (ALL with dash in the variable name) - first-name, last-name, phone-number, zip-code etc.
I also have to do sanity JAVAX validation( @Size
, @Pattern
etc. ) on these parameters, so I am consuming these params in a EmployeeRequest POJO ex. @Valid EmployeeRequest bean
.
But in have variable names are not allowed with hyphens, so its not working.
I can do this by using -
@RequestParam(value = "first-name,required = false) String firstName
But by doing so, my controller method will have tens of arguments and I have to Javax validation explicitly, so I am trying to do using Request POJO.
Please provide the advise how we handle it where we have multiple query param with hyphens in name and needs Javax validation in Spring Boot application.