MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / FlexibleGroupRule

Class FlexibleGroupRule

src/common/rule.ts:124–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124class FlexibleGroupRule<T> implements Rule {
125 predefined: Array<T>;
126 check: CheckFuction;
127 minimalVersion?: string;
128 constructor(
129 predefined: Array<T>,
130 options: readonly T[],
131 minimalVersion?: string
132 ) {
133 this.predefined = predefined;
134 this.minimalVersion = minimalVersion;
135 this.check = (value: Array<T | string>) => {
136 if (!value.map((item) => options.includes(item as T) || typeof item === "string").includes(false)) {
137 return true;
138 } else {
139 for (const item of value) {
140 if (!options.includes(item as T) && typeof item !== "string") {
141 console.log("check fail, invalid item", item);
142 }
143 }
144 return false;
145 }
146 };
147 }
148}
149// class CustomGroupRule<T> implements Rule {
150// predefined: Array<T>;
151// check: CheckFuction;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected