Spring does not support @javax.validation.Valid
on @PathVariable
annotated parameters in handler methods. There was an Improvement request, but it is still unresolved.
Your best bet is to just do your custom validation in the handler method body or consider using org.springframework.validation.annotation.Validated
as suggested in other answers.