Source:
<code>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"); <START> } <END> 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)); } } }</code><technical_language>If treating blank emails invalid emails email specified, change in "email, phone, externalId is required" section. null out blank emails, check email != null instead if isBlank(email)</technical_language>

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)); } } }