Esempio n. 1
0
        public static void ValidateEmail(Contact contact, ref Dictionary <String, List <String> > validationErrors)
        {
            List <String> emailErrors = new List <string>();

            if (String.IsNullOrEmpty(contact.EmailAddress))
            {
                emailErrors.Add("Email cannot be blank");
            }
            if (!RegexValidation.IsValidEmailAddress(contact.EmailAddress))
            {
                emailErrors.Add("Please enter a correctly formatted email address");
            }
            if (!String.IsNullOrEmpty(contact.EmailAddress) && contact.EmailAddress.Length > 80)
            {
                emailErrors.Add("Email length cannot exceed 80 characters");
            }

            if (emailErrors.Count > 0)
            {
                validationErrors.Add("Email", emailErrors);
            }
        }
Esempio n. 2
0
        public static void ValidateName(Contact contact, ref Dictionary <String, List <String> > validationErrors)
        {
            List <String> firstNameErrors = new List <string>();
            List <String> lastNameErrors  = new List <string>();

            if (String.IsNullOrEmpty(contact.FirstName))
            {
                firstNameErrors.Add("First name cannot be blank");
            }
            if (!RegexValidation.IsAlphabetic(contact.FirstName))
            {
                firstNameErrors.Add("Please input a valid first name");
            }
            if (!String.IsNullOrEmpty(contact.FirstName) && contact.FirstName.Length > 40)
            {
                firstNameErrors.Add("First name cannot be over 40 characters");
            }
            if (String.IsNullOrEmpty(contact.LastName))
            {
                lastNameErrors.Add("Last name cannot be blank");
            }
            if (!RegexValidation.IsAlphabetic(contact.LastName))
            {
                firstNameErrors.Add("Please input a valid last name");
            }
            if (!String.IsNullOrEmpty(contact.LastName) && contact.LastName.Length > 40)
            {
                firstNameErrors.Add("Last name cannot be over 40 characterss");
            }

            if (firstNameErrors.Count > 0)
            {
                validationErrors.Add("FirstName", firstNameErrors);
            }
            if (lastNameErrors.Count > 0)
            {
                validationErrors.Add("LastName", lastNameErrors);
            }
        }