Validation fixes, finished application creation, added required char (*) for required fields

This commit is contained in:
2024-09-08 14:13:08 +03:00
parent 142148368f
commit c128349f3b
34 changed files with 372 additions and 100 deletions

View File

@@ -1,4 +1,5 @@
using ApplicationLayer.InfrastructureServicesInterfaces;
using Domains;
using FluentValidation;
namespace ApplicationLayer.Services.VisaApplications.Models.Validation;
@@ -21,6 +22,10 @@ public class PastVisaModelValidator : AbstractValidator<PastVisaModel>
RuleFor(v => v.Name)
.NotEmpty()
.WithMessage("Name of past visa can not be empty");
.WithMessage("Name of past visa can not be empty")
.Matches(Constants.EnglishPhraseRegex)
.WithMessage("Name of past visa can contain only english letters, digits and special symbols")
.MaximumLength(ConfigurationConstraints.VisaNameLength)
.WithMessage($"Past visa name length must be less than {ConfigurationConstraints.VisaNameLength}");
}
}

View File

@@ -23,6 +23,8 @@ public class PastVisitModelValidator : AbstractValidator<PastVisitModel>
RuleFor(v => v.DestinationCountry)
.NotEmpty()
.WithMessage("Destination Country of past visit can not be null")
.Matches(Constants.EnglishPhraseRegex)
.WithMessage("Destination Country of past visit can contain only english letters, digits and special symbols")
.MaximumLength(ConfigurationConstraints.CountryNameLength)
.WithMessage($"Destination Country of past visit length must be less than {ConfigurationConstraints.CountryNameLength}");
}

View File

@@ -17,6 +17,8 @@ public class PermissionToDestCountryModelValidator : AbstractValidator<Permissio
RuleFor(p => p!.Issuer)
.NotEmpty()
.WithMessage("Issuer of permission for destination Country can not be empty")
.Matches(Constants.EnglishPhraseRegex)
.WithMessage("Issuer of permission for destination Country can contain only english letters, digits and special symbols")
.MaximumLength(ConfigurationConstraints.IssuerNameLength)
.WithMessage($"Issuer of permission to destination Country length must be less than {ConfigurationConstraints.IssuerNameLength}");
}

View File

@@ -11,6 +11,8 @@ public class ReentryPermitModelValidator : AbstractValidator<ReentryPermitModel?
RuleFor(p => p!.Number)
.NotEmpty()
.WithMessage("Re-entry permit number can not be empty")
.Matches(Constants.EnglishPhraseRegex)
.WithMessage("Re-entry permit number can contain only english letters, digits and special symbols")
.MaximumLength(ConfigurationConstraints.ReentryPermitNumberLength)
.WithMessage($"Re-entry permit number length must be less than {ConfigurationConstraints.ReentryPermitNumberLength}");