Source:
public void validate(Object object, Errors errors) { StudyParticipant participant = (StudyParticipant)object; if (isNew) { Phone phone = participant.getPhone(); String email = participant.getEmail(); String externalId = participant.getExternalId(); if (isBlank(email) && isBlank(externalId) && phone == null) { errors.reject("email, phone, or externalId is required"); } if (phone != null && !Phone.isValid(phone)) { errors.rejectValue("phone", "does not appear to be a phone number"); } if (email != null && !EMAIL_VALIDATOR.isValid(email)) { errors.rejectValue("email", "does not appear to be an email address"); } if (study.isExternalIdRequiredOnSignup() && isBlank(participant.getExternalId())) { errors.rejectValue("externalId", "is required"); } String password = participant.getPassword(); if (password != null) { PasswordPolicy passwordPolicy = study.getPasswordPolicy(); ValidatorUtils.validatePassword(errors, passwordPolicy, password); } } else { if (isBlank(participant.getId())) { errors.rejectValue("id", "is required"); } } if (study.isExternalIdValidationEnabled() && participant.getExternalId() != null) { ExternalIdentifier externalId = externalIdService.getExternalId(study.getStudyIdentifier(), participant.getExternalId()); if (externalId == null) { errors.rejectValue("externalId", "is not a valid external ID"); } } for (String dataGroup : participant.getDataGroups()) { if (!study.getDataGroups().contains(dataGroup)) { errors.rejectValue("dataGroups", messageForSet(study.getDataGroups(), dataGroup)); } } for (String attributeName : participant.getAttributes().keySet()) { if (!study.getUserProfileAttributes().contains(attributeName)) { errors.rejectValue("attributes", messageForSet(study.getUserProfileAttributes(), attributeName)); } } }

Target:
public void validate(Object object, Errors errors) { StudyParticipant participant = (StudyParticipant)object; if (isNew) { Phone phone = participant.getPhone(); String email = participant.getEmail(); String externalId = participant.getExternalId(); if (email == null && isBlank(externalId) && phone == null) { errors.reject("email, phone, or externalId is required"); } if (phone != null && !Phone.isValid(phone)) { errors.rejectValue("phone", "does not appear to be a phone number"); } if (email != null && !EMAIL_VALIDATOR.isValid(email)) { errors.rejectValue("email", "does not appear to be an email address"); } if (study.isExternalIdRequiredOnSignup() && isBlank(participant.getExternalId())) { errors.rejectValue("externalId", "is required"); } String password = participant.getPassword(); if (password != null) { PasswordPolicy passwordPolicy = study.getPasswordPolicy(); ValidatorUtils.validatePassword(errors, passwordPolicy, password); } } else { if (isBlank(participant.getId())) { errors.rejectValue("id", "is required"); } } if (study.isExternalIdValidationEnabled() && participant.getExternalId() != null) { ExternalIdentifier externalId = externalIdService.getExternalId(study.getStudyIdentifier(), participant.getExternalId()); if (externalId == null) { errors.rejectValue("externalId", "is not a valid external ID"); } } for (String dataGroup : participant.getDataGroups()) { if (!study.getDataGroups().contains(dataGroup)) { errors.rejectValue("dataGroups", messageForSet(study.getDataGroups(), dataGroup)); } } for (String attributeName : participant.getAttributes().keySet()) { if (!study.getUserProfileAttributes().contains(attributeName)) { errors.rejectValue("attributes", messageForSet(study.getUserProfileAttributes(), attributeName)); } } }