function verifyRequest()

in samples-ts/functions/weatherMonitor.ts [82:104]


function verifyRequest(request: any): void {
    if (!request) {
        throw new Error("An input object is required.");
    }
    if (!request.location) {
        throw new Error("A location input is required.");
    }
    if (!request.location.city) {
        throw new Error("A city is required on the location input.");
    }
    if (!request.location.country) {
        throw new Error("A country code is required on location input.");
    }
    if (
        (request.location.country === "USA" || request.location.country === "US") &&
        !request.location.state
    ) {
        throw new Error("A state code is required on location input for US locations.");
    }
    if (!request.phone) {
        throw new Error("A phone number input is required.");
    }
}