コード例 #1
0
        public PatientViewModelValidator(IFutureDateValidator futureDateValidator, INhsValidator nhsValidator, IClinicalSystemIdDescriptionProvider clinicalSystemIdDescriptionProvider)
        {
            RuleFor(model => model.ClinicalSystemId)
            .NotEmpty()
            .WithMessage(string.Format("{0} is mandatory", clinicalSystemIdDescriptionProvider.GetDescription()))
            .Length(1, 50)
            .WithMessage(string.Format("{0} must be less than 50 characters", clinicalSystemIdDescriptionProvider.GetDescription()));

            RuleFor(model => model.FirstName)
            .NotEmpty()
            .WithMessage("First name is mandatory")
            .Length(1, 50)
            .WithMessage("First name must be less than 50 characters");

            RuleFor(model => model.LastName)
            .NotEmpty()
            .WithMessage("Last name is mandatory")
            .Length(1, 50)
            .WithMessage("Last name must be less than 50 characters");;

            RuleFor(model => model.DateOfBirthViewModel)
            .NotNull()
            .SetValidator(new DateOfBirthViewModelValidator(futureDateValidator));

            RuleFor(model => model.GenderId)
            .NotEmpty()
            .WithMessage("Gender is mandatory");

            RuleFor(model => model.NhsNumber)
            .Must(nhsValidator.Valid)
            .WithMessage("NHS number is not valid");
        }
コード例 #2
0
        public void Setup()
        {
            _futureDateValidator = A.Fake <IFutureDateValidator>();
            _nhsValidator        = A.Fake <INhsValidator>();
            _clinicalSystemIdDescriptionProvider = A.Fake <IClinicalSystemIdDescriptionProvider>();

            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(Clinicalsystemid);
            A.CallTo(() => _futureDateValidator.Valid(A <DateTime?> ._)).Returns(true);
            A.CallTo(() => _nhsValidator.Valid(A <decimal?> ._)).Returns(true);
        }
コード例 #3
0
        public CreatePatientViewModelValidator(IFutureDateValidator futureDateValidator,
                                               IClinicalIdValidator clinicalIdValidator,
                                               INhsValidator nhsValidator,
                                               IClinicalSystemIdDescriptionProvider clinicalSystemIdDescriptionProvider)
            : base(futureDateValidator, nhsValidator, clinicalSystemIdDescriptionProvider)
        {
            RuleFor(model => model.NhsNumber)
            .Must(nhsValidator.Unique)
            .WithMessage("A person with this NHS Number already exists");

            RuleFor(model => model.ClinicalSystemId)
            .Must(clinicalIdValidator.Unique)
            .WithMessage(string.Format("A person with this {0} already exists", clinicalSystemIdDescriptionProvider.GetDescription()));
        }