Skip to content
Advertisement

Tag: validation

How do I retrieve default validation messages from Hibernate Validator?

I’m trying to retrieve a default validation error-message using MessageSource. The code I’m working with uses reflection to retrieve the value of the message parameter. On a constraint that does not override the message parameter, I would like to retrieve the default error message. When I invoke the message method on the validation annotation, I get {org.hibernate.validator.constraints.NotBlank.message} (for example, for

How to sanity check a date in Java

I find it curious that the most obvious way to create Date objects in Java has been deprecated and appears to have been “substituted” with a not so obvious to use lenient calendar. How do you check that a date, given as a combination of day, month, and year, is a valid date? For instance, 2008-02-31 (as in yyyy-mm-dd) would

Advertisement