Search code examples
javahibernatevalidationspring-mvchibernate-validator

Checking for predefined String value Hibernate Validator


I am trying to validate my form Data using Hibernate Validator in my Spring MVC application. I have a requirement where i need to check user input for predefined values which will not be allowed in the system.

for e.g if the value of firstName field is firstName, i want to fail the validation and tell user that this value is not allowed.

Can any one tell me how this can be achieved using hibernate validation


Solution

  • You can create a custom validator that implements ConstraintValidator. Please read this link: Hibernate validator