MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / validateChannelNameTemplate

Function validateChannelNameTemplate

src/services/joinToCreateService.js:30–69  ·  view source on GitHub ↗
(template)

Source from the content-addressed store, hash-verified

28]);
29
30export function validateChannelNameTemplate(template) {
31 if (!template || typeof template !== 'string') {
32 throw new TitanBotError(
33 'Invalid channel template: must be a non-empty string',
34 ErrorTypes.VALIDATION,
35 'Channel name template must be valid text.'
36 );
37 }
38
39 const normalizedTemplate = template.normalize('NFKC').replace(CONTROL_AND_INVISIBLE_CHARS_REGEX, '').trim();
40
41 if (normalizedTemplate.length > CHANNEL_NAME_MAX_LENGTH) {
42 throw new TitanBotError(
43 'Channel template exceeds maximum length',
44 ErrorTypes.VALIDATION,
45 `Channel name template cannot exceed ${CHANNEL_NAME_MAX_LENGTH} characters.`
46 );
47 }
48
49 if (/[@#:`]/.test(normalizedTemplate)) {
50 throw new TitanBotError(
51 'Channel template contains forbidden characters',
52 ErrorTypes.VALIDATION,
53 'Channel template cannot contain @, #, :, or backtick characters.'
54 );
55 }
56
57 const placeholders = normalizedTemplate.match(/\{[^}]+\}/g) || [];
58 for (const placeholder of placeholders) {
59 if (!ALLOWED_TEMPLATE_PLACEHOLDERS.has(placeholder)) {
60 throw new TitanBotError(
61 'Channel template contains unknown placeholders',
62 ErrorTypes.VALIDATION,
63 `Unknown placeholder: ${placeholder}. Allowed placeholders are ${Array.from(ALLOWED_TEMPLATE_PLACEHOLDERS).join(', ')}`
64 );
65 }
66 }
67
68 return true;
69}
70
71export function validateBitrate(bitrate) {
72 const bitrateNum = parseInt(bitrate);

Callers 4

formatChannelNameFunction · 0.85
initializeJoinToCreateFunction · 0.85
updateChannelConfigFunction · 0.85
createTemporaryChannelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected