ApexSensei

Drills Triggers

Require a Contact email domain

A before-trigger handler can reject a single record with a field-level addError.

Your task

Finish the validator so Contact Emails that are not blank must end with @example.com.

public class AS_4752F6B3261E_EmailValidator {
    public static void validate(List<Contact> contacts) {
        for (Contact item : contacts) {
            if (String.isBlank(item.Email)) {
                continue;
            }
        }
    }
}

Requirements

  1. acceptsAllowedDomain should pass
  2. rejectsOtherDomainOnEmailField should pass
  3. rejectsLookalikeDomains should pass
  4. allowsBlankEmails should pass
  5. protectsExistingRecordOnUpdate should pass
  6. handlesMixedBulkOfTwoHundred should pass

Sign in to open this drill