MCPcopy Create free account
hub / github.com/GoogleChrome/samples / validatePart

Method validatePart

google-drive-embeddings/src/parser.js:64–83  ·  view source on GitHub ↗

* Checks if a specific string part is generic or uninformative.

(part)

Source from the content-addressed store, hash-verified

62 * Checks if a specific string part is generic or uninformative.
63 */
64 static validatePart(part) {
65 const trimmed = part.trim();
66 if (trimmed.length < 2) {
67 return { valid: false, reason: 'Too short (must be at least 2 chars)' };
68 }
69 const lower = trimmed.toLowerCase();
70 if (this.BLACKLIST.has(lower)) {
71 return { valid: false, reason: `Contains generic keyword "${trimmed}"` };
72 }
73 if (this.NUMERIC_ONLY_REGEX.test(trimmed)) {
74 return { valid: false, reason: 'Contains only numbers/digits' };
75 }
76 if (this.TRACK_INDEX_ONLY_REGEX.test(trimmed)) {
77 return { valid: false, reason: 'Contains only a track/volume index' };
78 }
79 if (this.PLACEHOLDER_REGEX.test(trimmed)) {
80 return { valid: false, reason: 'Contains unresolved placeholder syntax' };
81 }
82 return { valid: true };
83 }
84
85 /**
86 * Main parsing routine. Splits and validates a filename.

Callers 1

parseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected