MCPcopy
hub / github.com/codebymitch/TitanBot / validateGuildConfigOrThrow

Function validateGuildConfigOrThrow

src/utils/schemas.js:212–237  ·  view source on GitHub ↗
(rawConfig, context = {})

Source from the content-addressed store, hash-verified

210}
211
212export function validateGuildConfigOrThrow(rawConfig, context = {}) {
213 const normalized = normalizeGuildConfig(rawConfig);
214 const parsed = GuildConfigSchema.safeParse(normalized);
215
216 if (parsed.success) {
217 return stripLegacyLoggingFields({
218 ...normalized,
219 logging: migrateLoggingConfig(normalized.logging, {}),
220 });
221 }
222
223 throw createError(
224 'Invalid guild configuration payload',
225 ErrorTypes.VALIDATION,
226 'Configuration payload is invalid. Please review provided values and try again.',
227 {
228 ...context,
229 errorCode: 'VALIDATION_FAILED',
230 issues: parsed.error.issues.map((issue) => ({
231 path: issue.path.join('.'),
232 message: issue.message,
233 code: issue.code
234 }))
235 }
236 );
237}

Callers 4

setMethod · 0.90
setGuildConfigFunction · 0.90
guildConfig.jsFile · 0.90

Calls 4

createErrorFunction · 0.90
normalizeGuildConfigFunction · 0.85
stripLegacyLoggingFieldsFunction · 0.85
migrateLoggingConfigFunction · 0.85

Tested by

no test coverage detected