private void validateCustomerEmail(String customerEmail) throws InvalidSeatHoldRequestException { if (customerEmail == null || customerEmail.isEmpty()) { throw new InvalidSeatHoldRequestException("Customer email cannot be null or empty"); } if (!emailValidator.isValid(customerEmail, null)) { throw new InvalidSeatHoldRequestException( String.format("%s is not a valid email address", customerEmail)); } }
/** * Fails if both the input field for manual email address input is empty and there is no csv file * with content */ @Override public void validate(Object target, Errors errors) { InvitationForm form = (InvitationForm) target; if (StringUtils.hasText(form.getEmails())) { String[] emails = form.getEmails().split(","); for (String email : emails) { if (!EMAIL_VALIDATOR.isValid(email.trim(), null)) { errors.rejectValue("emails", "error.WrongFormattedEmailList"); break; } } } if (form.hasCsvFile() && form.getCsvFile().isEmpty()) { errors.rejectValue("csvFile", "invite.errors.EmptyCSV"); } if (!StringUtils.hasText(form.getEmails()) && !form.hasCsvFile()) { errors.rejectValue("emails", "invite.errors.NoEmailAddresses"); } }