Esempio n. 1
0
        //Reprocess the FamilyName before checking
        public List <int> VerifyFamilyName()
        {
            if (string.IsNullOrEmpty(FamilyName) || string.IsNullOrWhiteSpace(FamilyName))
            {
                return new List <int> {
                           11
                }
            }
            ;

            FamilyName = HelperProvider.CapitalizeFirstLetterOfEachWord(FamilyName.Trim());
            var errors = new List <int>();

            var lenTest = new Regex(@".{1,30}");

            if (!lenTest.IsMatch(FamilyName))
            {
                errors.Add(12);
            }

            var spTest = new Regex(@"^[A-Za-z_\-.'() ]*$");

            if (!spTest.IsMatch(FamilyName))
            {
                errors.Add(13);
            }

            return(errors);
        }
Esempio n. 2
0
 protected override void OnValidate()
 {
     if (string.IsNullOrWhiteSpace(GivenName) || GivenName.Trim().Length == 1)
     {
         AddError("GivenName", "Given name is not valid");
     }
     if (string.IsNullOrWhiteSpace(FamilyName) || FamilyName.Trim().Length == 1)
     {
         AddError("FamilyName", "Family name is not valid");
     }
     if (DateOfBirth > DateTime.Today)
     {
         AddError("DateOfBirth", "Date of birth is not in the past");
     }
     if (Address.HasErrors)
     {
         AddError("Address", "Address is not valid");
     }
 }