MCPcopy Create free account
hub / github.com/github/awesome-copilot / validateKeywords

Function validateKeywords

eng/validate-plugins.mjs:46–66  ·  view source on GitHub ↗
(keywords)

Source from the content-addressed store, hash-verified

44}
45
46function validateKeywords(keywords) {
47 if (keywords === undefined) return null;
48 if (!Array.isArray(keywords)) {
49 return "keywords must be an array";
50 }
51 if (keywords.length > 10) {
52 return "maximum 10 keywords allowed";
53 }
54 for (const keyword of keywords) {
55 if (typeof keyword !== "string") {
56 return "all keywords must be strings";
57 }
58 if (!/^[a-z0-9-]+$/.test(keyword)) {
59 return `keyword "${keyword}" must contain only lowercase letters, numbers, and hyphens`;
60 }
61 if (keyword.length < 1 || keyword.length > 30) {
62 return `keyword "${keyword}" must be between 1 and 30 characters`;
63 }
64 }
65 return null;
66}
67
68function arraysEqual(left, right) {
69 if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) {

Callers 1

validatePluginFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected