GuestOps/src/GuestOps.Core/BookingValidation.cs

24 lines
1.3 KiB
C#

using GuestOps.Models;
namespace GuestOps.Services;
public static class BookingValidation
{
public static bool IsCurrency(string? value) => value != null && value.Length == 3 && value.All(c => c is >= 'A' and <= 'Z' or >= 'a' and <= 'z');
public static string? Stay(ParsedBooking row)
{
if (row.Rooms != 1) return "Multi-room requests require staff handling; split into individually priced reservations before taking payment.";
if (!row.ArrivalDate.HasValue || !row.DepartureDate.HasValue || row.DepartureDate <= row.ArrivalDate || row.ArrivalDate.Value.Date < DateTime.Today)
return "A valid future arrival and later departure are required.";
if (row.Adults < 1 || row.Children < 0) return "Guest counts are invalid.";
return null;
}
public static string? Validate(ParsedBooking row)
{
if (row.IsAutomaticMessage) return "Automated/list/bounce messages are not eligible for processing.";
if (row.Action == BookingAction.None) return "Review or reparse this email; no supported action is selected.";
if (row.Action is BookingAction.CreateBooking or BookingAction.QuoteRequest) return Stay(row);
if (string.IsNullOrWhiteSpace(row.ConfirmationNumber)) return "A confirmation number is required.";
return null;
}
}