2

I have found two custom annotation solution as mention below.

https://stackoverflow.com/a/41718607/8123983

https://gist.github.com/robinraju/875b08694c80836273ebb9b6e5783f77

But, I am looking for any default implementation of hibernate validator.

S_K
  • 700
  • 1
  • 8
  • 13
  • Why would you want one? – SamHoque Dec 27 '18 at 07:25
  • @SamzSakerz I have to add a custom annotation with every new project development. Which is quite easy, if there is any default solution from hibernate. – S_K Dec 27 '18 at 09:20
  • what if you use Spring's `org.springframework.format.annotation.DateTimeFormat` annotation? Like `DateTimeFormat(iso = ISO.DATE)`, means the format of date should be - `yyyy-MM-dd` – BSeitkazin Dec 27 '18 at 09:49
  • @BSeitkazin This is a good solution for specifically yyyy-MM-dd format. Thanks. – S_K Dec 31 '18 at 05:36

1 Answers1

0

No Inbuilt validators for Date Format , These are the default validators that can be applied to date or calendars field types.

  • @Past property (date or calendar) -check if the date is in the past
  • @Future property (date or calendar) -check if the date is in the future

If you need to apply for String property , then only @Pattern validator javax.validation.constraints.Pattern regexp(mandatory) is useful for your case.

Yugansh
  • 365
  • 3
  • 9