コード例 #1
0
        public PersonalDataBirthdayValidator()
        {
            this.CascadeMode = CascadeMode.StopOnFirstFailure;

            RuleFor(x => x.Birthday)
            .NotEmpty();

            RuleFor(x => x.Birthday)
            .SetValidator(new DateTimeValueValidator());

            RuleFor(x => x.BirthdayD)
            .LessThan(DateTime.Today)
            .Unless(x => string.IsNullOrEmpty(x.Birthday))
            .WithMessage(Validationmessages.BirthdayNotInFuture);

            RuleFor(x => x.BirthdayD)
            .GreaterThanOrEqualTo(new DateTime(1900, 01, 01))
            .Unless(x => string.IsNullOrEmpty(x.Birthday));

            RuleFor(x => x.BirthdayD)
            .Must(CheckDates)
            .Unless(x => string.IsNullOrEmpty(x.Birthday) || !SSNHelper.IsValid(x.Ssn))
            .WithSeverity(Severity.Warning)
            .WithMessage(x => Validationmessages.BirthdayNotInSsn(x));
        }
コード例 #2
0
        public PersonalDataSsnValidator()
        {
            this.CascadeMode = CascadeMode.StopOnFirstFailure;

            RuleFor(x => x.Ssn)
            .NotEmpty();

            RuleFor(x => x.Ssn)
            .Must(x => SSNHelper.IsValid(x))
            .WithMessage(Validationmessages.SsnNotValid);
        }
コード例 #3
0
        private bool CheckDates(PersonalData data, DateTime date)
        {
            if (date == null)
            {
                return(false);
            }

            var date2 = SSNHelper.GetBirthDay(data.Ssn);

            if (!date2.HasValue)
            {
                return(true);
            }

            return(date2.Value.ToString("ddMMyy") == date.ToString("ddMMyy"));
        }
コード例 #4
0
 public static string BirthdayNotInSsn(PersonalData data) => $"Das Geburtsdatum {data.BirthdayD.ToString("dd.MM.yyyy")} unterscheidet sich vom Wert in der Versicherungsnummer {SSNHelper.Format(data.Ssn).Substring(5)}.";