"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.locationsResponseSchema = exports.locationResponseSchema = exports.updateLocationSchema = exports.createLocationSchema = void 0;
const zod_1 = require("zod");
const shared_dto_1 = require("../shared/shared.dto");
const optionalString = zod_1.z.preprocess((value) => {
    if (typeof value === 'string' && value.trim() === '')
        return undefined;
    return value;
}, zod_1.z.string().trim().optional());
const statusSchema = zod_1.z.enum(['active', 'inactive', 'deleted']);
exports.createLocationSchema = zod_1.z.object({
    name: zod_1.z
        .string()
        .trim()
        .min(2, { message: 'Location name must be at least 2 characters long' }),
    location_code: zod_1.z
        .string()
        .trim()
        .min(1, { message: 'Location code is required' }),
    description: optionalString,
    status: statusSchema.optional(),
});
exports.updateLocationSchema = exports.createLocationSchema
    .partial()
    .refine((data) => Object.keys(data).length > 0, {
    message: 'At least one field must be provided',
});
exports.locationResponseSchema = zod_1.z.object({
    id: zod_1.z.string().uuid().optional(),
    name: zod_1.z.string().optional(),
    location_code: zod_1.z.string().optional(),
    description: shared_dto_1.defaultTransformSchema,
    status: statusSchema.optional(),
    created_at: shared_dto_1.dateTransformSchema,
    updated_at: shared_dto_1.dateTransformSchema,
});
exports.locationsResponseSchema = zod_1.z.array(exports.locationResponseSchema);
//# sourceMappingURL=locations.dto.js.map