示例#1
0
        //Reprocess the GivenName before checking
        public List <int> VerifyGivenName()
        {
            if (string.IsNullOrEmpty(GivenName) || string.IsNullOrWhiteSpace(GivenName))
            {
                return new List <int> {
                           14
                }
            }
            ;

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

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

            if (!lenTest.IsMatch(GivenName))
            {
                errors.Add(15);
            }

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

            if (!spTest.IsMatch(GivenName))
            {
                errors.Add(16);
            }

            return(errors);
        }
示例#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");
     }
 }
示例#3
0
 /// <inheritdoc />
 public bool IsValid() => GivenName.Trim() + FamilyName.Trim() != "";