| 122 | } |
| 123 | |
| 124 | class 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; |
nothing calls this directly
no outgoing calls
no test coverage detected