GuestLog - Improvements to GuestDocument creation

- Added DocumentNumber validations.
- Added new page to see GuestDocument details.
This commit is contained in:
2026-07-30 20:31:13 +02:00
parent 5061f9362b
commit a5eea09eee
13 changed files with 465 additions and 42 deletions
@@ -1,6 +1,7 @@
using FluentValidation;
using Somnia.GuestLog.Models.DTOs;
using Somnia.GuestLog.Services;
using Somnia.GuestLog.Utils;
namespace Somnia.GuestLog.Validators;
@@ -12,6 +13,7 @@ public class GuestDocumentDTOValidator : AbstractValidator<GuestDocumentDTO>
public GuestDocumentDTOValidator(IDataListService dataListService)
{
RuleFor(x => x.DocumentType)
.Cascade(CascadeMode.Stop)
.NotEmpty()
.Must(val => val != null && dataListService.IsValueInList(GuestConsts.DataList_DocumentTypes, val));
@@ -23,6 +25,12 @@ public class GuestDocumentDTOValidator : AbstractValidator<GuestDocumentDTO>
.NotEmpty()
.LessThanOrEqualTo(DateTime.Today);
RuleFor(x => x.SupportNum)
.Cascade(CascadeMode.Stop)
.NotEmpty()
.Matches(RegexUtils.RegexGuestDocSuportNumber()).WithMessage("Invalid Format. Expected 'AAA000000'.")
.When(x => x.Nationality == GuestConsts.CountryCode_ESP);
RuleFor(x => x.Name)
.NotEmpty()
.Length(1, 100);
@@ -36,6 +44,7 @@ public class GuestDocumentDTOValidator : AbstractValidator<GuestDocumentDTO>
.LessThanOrEqualTo(DateTime.Today);
RuleFor(x => x.Nationality)
.Cascade(CascadeMode.Stop)
.NotEmpty()
.Must(val => val != null && dataListService.IsValueInList(GuestConsts.DataList_CountryCodes, val));
@@ -53,12 +62,6 @@ public class GuestDocumentDTOValidator : AbstractValidator<GuestDocumentDTO>
.NotEmpty()
.Must(val => val != null && dataListService.IsValueInList(GuestConsts.DataList_CountryCodes, val));
// RuleFor(x => x.Email)
// .Cascade(CascadeMode.Stop)
// .NotEmpty()
// .EmailAddress()
// .MustAsync(async (value, _) => await IsUniqueAsync(value));
// RuleFor(x => x.CCNumber)
// .NotEmpty()
// .Length(1, 100)