"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuditorContact = exports.AuditorContactSchema = exports.AuditorContactValidationSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const joi_1 = __importDefault(require("joi"));
const _models_1 = require("./_models");
exports.AuditorContactValidationSchema = joi_1.default.object({
    _id: joi_1.default.string(),
    auditorId: joi_1.default.string(),
    name: joi_1.default.string().required(),
    email: joi_1.default.string().allow(''),
    phone: joi_1.default.string().allow(''),
    comment: joi_1.default.string().allow(''),
    isDeleted: joi_1.default.boolean(),
    order: joi_1.default.number().required().allow(null),
});
exports.AuditorContactSchema = new mongoose_1.default.Schema({
    auditorId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.auditors,
        required: true,
    },
    isDeleted: {
        type: Boolean,
        default: false,
    },
    name: {
        type: String,
        required: true,
    },
    email: {
        type: String,
    },
    normalizedEmail: {
        type: String,
        lowercase: true,
        select: false,
        unique: true,
    },
    phone: {
        type: String,
    },
    comment: {
        type: String,
    },
    order: {
        type: Number,
        required: true,
    },
}, {
    timestamps: { createdAt: true, updatedAt: true },
    versionKey: false,
});
exports.AuditorContact = mongoose_1.default.model(_models_1.MODEL_NAMES.auditorContact, exports.AuditorContactSchema);
