Search code examples
javahibernategwthibernate-validator

How to validate a single field with Hibernate Validator?


I'm looking for a way to validate a single field at a time. This is so, while a user is filling in a form, each time the keypress or blur event occurs for each field, i can validate that field individually and show / hide its error message.

Is that possible? If so, how can I do it? Some google searching hasn't turned up any results which validate a single field, rather than the whole form.


Solution

  • You can use javax.validation.Validator#validateProperty() for that purpose.