Skip to content

Commit 0229fd8

Browse files
Add podcast:txt validation rule.
1 parent 060dad2 commit 0229fd8

File tree

4 files changed

+48
-288
lines changed

4 files changed

+48
-288
lines changed

validator-worker/common/qnames.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class Qnames {
6363
source: _podcastIndex('source'),
6464
trailer: _podcastIndex('trailer'),
6565
transcript: _podcastIndex('transcript'),
66+
txt: _podcastIndex('txt'),
6667
value: _podcastIndex('value'),
6768
valueRecipient: _podcastIndex('valueRecipient'),
6869
}

validator-worker/common/validator.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ function validateChannel(channel: ExtendedXmlNode, callbacks: ValidationCallback
232232
}
233233
callbacks.onPodcastIndexLiveItemsFound(liveItems.length);
234234

235-
236235
// PHASE 5
237236

238237
// podcast:block
@@ -251,6 +250,10 @@ function validateChannel(channel: ExtendedXmlNode, callbacks: ValidationCallback
251250
.checkValue(isYesNo)
252251
.checkRemainingAttributes();
253252

253+
// PHASE 6
254+
255+
// podcast:txt
256+
checkPodcastTxt('channel', channel, callbacks);
254257

255258
// PROPOSALS
256259

@@ -371,6 +374,17 @@ function checkPodcastImages(level: Level, node: ExtendedXmlNode, callbacks: Vali
371374
.checkRemainingAttributes();
372375
}
373376

377+
function checkPodcastTxt(level: Level, node: ExtendedXmlNode, callbacks: ValidationCallbacks) {
378+
const txts = findChildElements(node, ...Qnames.PodcastIndex.txt);
379+
const txtReference = podcastIndexReference('https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#txt');
380+
for (const txt of txts) {
381+
ElementValidation.forElement(level, txt, callbacks, txtReference)
382+
.checkOptionalAttribute('purpose', isAtMostCharacters(128))
383+
.checkValue(isAtMostCharacters(4000))
384+
.checkRemainingAttributes();
385+
}
386+
}
387+
374388
function checkPodcastTagUsage(node: ExtendedXmlNode, callbacks: ValidationCallbacks) {
375389
const known = new Set<string>();
376390
const unknown = new Set<string>();
@@ -576,6 +590,11 @@ function validateItem(item: ExtendedXmlNode, callbacks: ValidationCallbacks, ite
576590
callbacks.onGood(socialInteract, `Found ${itemTagName} <podcast:socialInteract>, nice!`, { tag: 'social-interact', reference: socialInteractReference });
577591
}
578592

593+
// PHASE 6
594+
595+
// podcast:txt
596+
checkPodcastTxt('item', item, callbacks);
597+
579598
// PROPOSALS
580599

581600
// (none at the moment)

0 commit comments

Comments
 (0)