"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.postalCodeQuerySchema = exports.postalCodeParamSchema = void 0;
exports.normalizePostalCode = normalizePostalCode;
exports.isValidCanadianPostalCode = isValidCanadianPostalCode;
const zod_1 = require("zod");
/** Strip spaces, uppercase */
function normalizePostalCode(raw) {
    return raw.replace(/\s/g, '').toUpperCase();
}
/** Validate Canadian postal code (all provinces) */
function isValidCanadianPostalCode(code) {
    return /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]\d[ABCEGHJKLMNPRSTVWXYZ]\d$/.test(code);
}
exports.postalCodeParamSchema = zod_1.z.object({
    postalCode: zod_1.z
        .string()
        .transform(normalizePostalCode)
        .refine(isValidCanadianPostalCode, { message: 'Invalid Canadian postal code' }),
});
exports.postalCodeQuerySchema = zod_1.z.object({
    refresh: zod_1.z.enum(['true', 'false']).optional().default('false'),
});
//# sourceMappingURL=postal-codes.schemas.js.map