I'm working with Spring-boot to expose REST Api and I need to check two differents patterns of date for my input DTO. For now, my code checks the format
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
but I need to give to client possibility to send date also with the format "yyyy-MM.
One of solutions is tu use annotation @Pattern rather than @JsonFormat annotation but the neede regex to validate the two dates is too long, I want to know if there is a better solution.