file-scoped namespaces
This commit is contained in:
		| @@ -2,12 +2,12 @@ | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class PastVisaValidator : AbstractValidator<PastVisa> | ||||
| { | ||||
|     public class PastVisaValidator : AbstractValidator<PastVisa> | ||||
|     public PastVisaValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public PastVisaValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(v => v.ExpirationDate) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Expiration date of past visa can not be empty") | ||||
| @@ -24,5 +24,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Name of past visa can not be empty"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -3,12 +3,12 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class PastVisitValidator : AbstractValidator<PastVisit> | ||||
| { | ||||
|     public class PastVisitValidator : AbstractValidator<PastVisit> | ||||
|     public PastVisitValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public PastVisitValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(v => v.StartDate) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Start date of past visit can not be empty") | ||||
| @@ -27,5 +27,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .MaximumLength(ConfigurationConstraints.CountryNameLength) | ||||
|                 .WithMessage($"Destination Country of past visit length must be less than {ConfigurationConstraints.CountryNameLength}"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -3,12 +3,12 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class PermissionToDestCountryValidator : AbstractValidator<PermissionToDestCountry?> | ||||
| { | ||||
|     public class PermissionToDestCountryValidator : AbstractValidator<PermissionToDestCountry?> | ||||
|     public PermissionToDestCountryValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public PermissionToDestCountryValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(p => p!.ExpirationDate) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Expiration date of permission to destination Country can not be empty") | ||||
| @@ -21,5 +21,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .MaximumLength(ConfigurationConstraints.IssuerNameLength) | ||||
|                 .WithMessage($"Issuer of permission to destination Country length must be less than {ConfigurationConstraints.IssuerNameLength}"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -3,12 +3,12 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class ReentryPermitValidator : AbstractValidator<ReentryPermit?> | ||||
| { | ||||
|     public class ReentryPermitValidator : AbstractValidator<ReentryPermit?> | ||||
|     public ReentryPermitValidator(IDateTimeProvider dateTimeProvider) | ||||
|     { | ||||
|         public ReentryPermitValidator(IDateTimeProvider dateTimeProvider) | ||||
|         { | ||||
|             RuleFor(p => p!.Number) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Re-entry permit number can not be empty") | ||||
| @@ -21,5 +21,4 @@ namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
|                 .GreaterThan(dateTimeProvider.Now()) | ||||
|                 .WithMessage("Re-entry permit must not be expired"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -4,51 +4,50 @@ using Domains; | ||||
| using Domains.VisaApplicationDomain; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation | ||||
| namespace ApplicationLayer.Services.VisaApplications.Requests.Validation; | ||||
|  | ||||
| public class VisaApplicationCreateRequestValidator : AbstractValidator<VisaApplicationCreateRequest> | ||||
| { | ||||
|     public class VisaApplicationCreateRequestValidator : AbstractValidator<VisaApplicationCreateRequest> | ||||
|     public VisaApplicationCreateRequestValidator( | ||||
|         IValidator<ReentryPermit?> reentryPermitValidator, | ||||
|         IValidator<PastVisa> pastVisaValidator, | ||||
|         IValidator<PermissionToDestCountry?> permissionToDestCountryValidator, | ||||
|         IValidator<PastVisit> pastVisitValidator, | ||||
|         IApplicantsRepository applicants, | ||||
|         IUserIdProvider userIdProvider) | ||||
|     { | ||||
|         public VisaApplicationCreateRequestValidator( | ||||
|             IValidator<ReentryPermit?> reentryPermitValidator, | ||||
|             IValidator<PastVisa> pastVisaValidator, | ||||
|             IValidator<PermissionToDestCountry?> permissionToDestCountryValidator, | ||||
|             IValidator<PastVisit> pastVisitValidator, | ||||
|             IApplicantsRepository applicants, | ||||
|             IUserIdProvider userIdProvider) | ||||
|         { | ||||
|             RuleFor(r => r.ReentryPermit) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Non-residents must provide re-entry permission") | ||||
|                 .SetValidator(reentryPermitValidator) | ||||
|                 .WhenAsync(async (r, ct) => | ||||
|                     await applicants.IsApplicantNonResidentByUserId(userIdProvider.GetUserId(), ct)); | ||||
|         RuleFor(r => r.ReentryPermit) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Non-residents must provide re-entry permission") | ||||
|             .SetValidator(reentryPermitValidator) | ||||
|             .WhenAsync(async (r, ct) => | ||||
|                 await applicants.IsApplicantNonResidentByUserId(userIdProvider.GetUserId(), ct)); | ||||
|  | ||||
|             RuleFor(r => r.DestinationCountry) | ||||
|                 .NotEmpty() | ||||
|                 .WithMessage("Destination country can not be empty"); | ||||
|         RuleFor(r => r.DestinationCountry) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Destination country can not be empty"); | ||||
|  | ||||
|             RuleFor(r => r.VisaCategory) | ||||
|                 .IsInEnum(); | ||||
|         RuleFor(r => r.VisaCategory) | ||||
|             .IsInEnum(); | ||||
|  | ||||
|             RuleFor(r => r.RequestedNumberOfEntries) | ||||
|                 .IsInEnum(); | ||||
|         RuleFor(r => r.RequestedNumberOfEntries) | ||||
|             .IsInEnum(); | ||||
|  | ||||
|             RuleFor(r => r.ValidDaysRequested) | ||||
|                 .GreaterThan(0) | ||||
|                 .WithMessage($"Valid days requested should be positive number and less than {ConfigurationConstraints.MaxValidDays}") | ||||
|                 .LessThanOrEqualTo(ConfigurationConstraints.MaxValidDays) | ||||
|                 .WithMessage($"Valid days requested must be less than or equal to {ConfigurationConstraints.MaxValidDays}"); | ||||
|         RuleFor(r => r.ValidDaysRequested) | ||||
|             .GreaterThan(0) | ||||
|             .WithMessage($"Valid days requested should be positive number and less than {ConfigurationConstraints.MaxValidDays}") | ||||
|             .LessThanOrEqualTo(ConfigurationConstraints.MaxValidDays) | ||||
|             .WithMessage($"Valid days requested must be less than or equal to {ConfigurationConstraints.MaxValidDays}"); | ||||
|  | ||||
|             RuleForEach(r => r.PastVisas) | ||||
|                 .SetValidator(pastVisaValidator); | ||||
|         RuleForEach(r => r.PastVisas) | ||||
|             .SetValidator(pastVisaValidator); | ||||
|  | ||||
|             When(r => r.VisaCategory == VisaCategory.Transit, | ||||
|                 () => | ||||
|                     RuleFor(r => r.PermissionToDestCountry) | ||||
|                         .SetValidator(permissionToDestCountryValidator)); | ||||
|         When(r => r.VisaCategory == VisaCategory.Transit, | ||||
|             () => | ||||
|                 RuleFor(r => r.PermissionToDestCountry) | ||||
|                     .SetValidator(permissionToDestCountryValidator)); | ||||
|  | ||||
|             RuleForEach(r => r.PastVisits) | ||||
|                 .SetValidator(pastVisitValidator); | ||||
|         } | ||||
|         RuleForEach(r => r.PastVisits) | ||||
|             .SetValidator(pastVisitValidator); | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user