
function validateLocale(req, res, next) {
    const { locale } = req.params;
    
    if (!locale || typeof locale !== 'string') {
        return res.status(400).json({
            success: false,
            error: 'Locale parameter is required'
        });
    }

    if (!/^[a-zA-Z0-9_-]{2,10}$/.test(locale)) {
        return res.status(400).json({
            success: false,
            error: 'Invalid locale format. Use 2-10 alphanumeric characters, hyphens, or underscores.'
        });
    }
    
    next();
}

function validateConfigKey(req, res, next) {
    const { key } = req.params;
    
    if (!key || typeof key !== 'string' || key.length === 0) {
        return res.status(400).json({
            success: false,
            error: 'Config key parameter is required'
        });
    }
    
    if (/[<>\"'&]/.test(key)) {
        return res.status(400).json({
            success: false,
            error: 'Invalid config key format'
        });
    }
    
    next();
}

module.exports = {
    validateLocale,
    validateConfigKey
};
