feat(flight-finder): implement milestone M2 - report workflow and delivery gates
This commit is contained in:
@@ -6,6 +6,7 @@ import type {
|
||||
FlightSearchPreferences,
|
||||
NormalizedFlightReportRequest
|
||||
} from "./types.js";
|
||||
import { isPlausibleEmail, normalizeMarketCountry } from "./input-validation.js";
|
||||
|
||||
const DEFAULT_PREFERENCES: FlightSearchPreferences = {
|
||||
preferOneStop: true,
|
||||
@@ -34,30 +35,6 @@ function uniqueStrings(values: Array<string | null | undefined> | undefined): st
|
||||
return cleaned.length ? Array.from(new Set(cleaned)) : undefined;
|
||||
}
|
||||
|
||||
function normalizeMarketCountry(value: string | null | undefined): string | null | undefined {
|
||||
const cleaned = cleanString(value);
|
||||
if (!cleaned) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = cleaned.toUpperCase();
|
||||
if (!/^[A-Z]{2}$/.test(normalized)) {
|
||||
throw new Error(
|
||||
`Invalid marketCountry "${value}". Use an ISO 3166-1 alpha-2 uppercase country code such as "TH" or "DE".`
|
||||
);
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function isPlausibleEmail(value: string | null | undefined): boolean {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
||||
}
|
||||
|
||||
function normalizePassengerGroups(
|
||||
groups: FlightReportRequestDraft["passengerGroups"]
|
||||
): FlightPassengerGroup[] {
|
||||
|
||||
Reference in New Issue
Block a user