class urn_perun_user_attribute_def_def_o365UserEmailAddresses_mu extends UserAttributesModuleAbstract {

	@Override
	public void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute) throws InternalErrorException, WrongAttributeValueException {
		//empty value is valid
		if(attribute.getValue() == null) return;
		ArrayList<String> emails = attribute.valueAsList();

		//check syntax of all values
		for (String email : emails) {
			Matcher emailMatcher = emailPattern.matcher(email);
			if (!emailMatcher.matches())
				throw new WrongAttributeValueException(attribute, user, "Email " + email + " is not in correct form.");
			Matcher ucoEmailMatcher = ucoEmailPattern.matcher(email);
			if (ucoEmailMatcher.matches())
				throw new WrongAttributeValueException(attribute, user, "Email " + email + " is based on UCO which is not supported.");
		}

		//check for duplicities
		if (hasDuplicate(emails)) {
			throw new WrongAttributeValueException(attribute, user, "duplicate values");
		}
	}

}