(key: Identifier, value: any)
| 97 | } |
| 98 | |
| 99 | checkStatus(key: Identifier, value: any): CheckResult { |
| 100 | if (value == undefined) { |
| 101 | return { |
| 102 | canSave: false, |
| 103 | canEnable: false, |
| 104 | saveReason: "配置为空", |
| 105 | enableReason: "配置为空", |
| 106 | }; |
| 107 | } |
| 108 | const check = this.getRule(key).check; |
| 109 | if (!check) { |
| 110 | return { canSave: true, canEnable: true }; |
| 111 | } |
| 112 | const status = this.normalizeCheckResult(check(value)); |
| 113 | if (!status.canSave && !status.saveReason) { |
| 114 | status.saveReason = "配置未通过校验"; |
| 115 | } |
| 116 | if (!status.canEnable && !status.enableReason) { |
| 117 | status.enableReason = "配置未通过校验"; |
| 118 | } |
| 119 | return status; |
| 120 | } |
| 121 | |
| 122 | private normalizeCheckResult(result: boolean | CheckResult): CheckResult { |
| 123 | if (typeof result === "boolean") { |
no test coverage detected