You must use the validate method with the following signature:
public Map<String, List<ValidationError>> validate()
Thus, you can add errors to single fields as follows:
Map<String, List<ValidationError>> errors = null; if (emailIsBad) { errors = new HashMap<String, List<ValidationError>>(); List<ValidationError> list = new ArrayList<ValidationError>(); list.add(new ValidationError("email", "email is bad")); errors.put("email", list); } return errors;
note that if you must return a blank card, it will still make the form erroneous. If you want the validate() method to succeed, you need to return null.
source share