"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateRequired = validateRequired;
function validateRequired(options, config) {
    const value = options[config.name];
    // Check if value is missing
    if (value === undefined || value === null || value === '') {
        let message = `Missing required option: '${config.name}'\n`;
        message += `  Description: ${config.description}\n`;
        if (config.allowedValues) {
            message += `  Allowed values: ${config.allowedValues.join(', ')}\n`;
        }
        if (config.type) {
            message += `  Type: ${config.type}\n`;
        }
        if (config.pattern) {
            message += `  Pattern: ${config.pattern}\n`;
        }
        throw new Error(message.trim());
    }
    // Check pattern if provided
    if (config.pattern && typeof value === 'string') {
        const regex = new RegExp(config.pattern);
        if (!regex.test(value)) {
            let message = `Invalid value '${value}' for option '${config.name}'\n`;
            message += `  Pattern: ${config.pattern}\n`;
            message += `  Received: ${value}`;
            throw new Error(message);
        }
    }
    // Check enum if provided
    if (config.allowedValues && !config.allowedValues.includes(value)) {
        let message = `Invalid value '${value}' for option '${config.name}'\n`;
        message += `  Allowed values: ${config.allowedValues.join(', ')}\n`;
        message += `  Received: ${value}`;
        throw new Error(message);
    }
}
