MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / GroupRule

Class GroupRule

src/common/rule.ts:98–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98class GroupRule<T> implements Rule {
99 predefined: Array<T>;
100 check: CheckFuction;
101 minimalVersion?: string;
102 constructor(
103 predefined: Array<T>,
104 options: readonly T[],
105 minimalVersion?: string
106 ) {
107 this.predefined = predefined;
108 this.minimalVersion = minimalVersion;
109 this.check = (value: Array<T>) => {
110 if (!value.map((item) => options.includes(item)).includes(false)) {
111 return true;
112 } else {
113 for (const item of value) {
114 if (!options.includes(item)) {
115 console.log("check fail, invalid item", item);
116 }
117 }
118 return false;
119 }
120 };
121 }
122}
123
124class FlexibleGroupRule<T> implements Rule {
125 predefined: Array<T>;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected