(value: KeyConfig)
| 94 | |
| 95 | // 检查是否全空或全填写 |
| 96 | function emptyOrAllCheck(value: KeyConfig): CheckResult { |
| 97 | const invalidKeys = getInvalidStringKeys(value); |
| 98 | if (invalidKeys.length > 0) { |
| 99 | const reason = `字段类型无效: ${invalidKeys.join(", ")}`; |
| 100 | return { canSave: false, canEnable: false, saveReason: reason, enableReason: reason }; |
| 101 | } |
| 102 | const emptyKeys = getEmptyKeys(value); |
| 103 | const allEmpty = emptyKeys.length === Object.keys(value).length; |
| 104 | const allFilled = emptyKeys.length === 0; |
| 105 | if (allEmpty) { // 全空也行,就用系统默认的 |
| 106 | return { |
| 107 | canSave: true, |
| 108 | canEnable: true, |
| 109 | }; |
| 110 | } |
| 111 | // 全部填写也行 |
| 112 | if (allFilled) { |
| 113 | return { canSave: true, canEnable: true }; |
| 114 | } |
| 115 | return { |
| 116 | canSave: false, |
| 117 | canEnable: false, |
| 118 | saveReason: "要么全填写所有字段,要么全不填写", |
| 119 | enableReason: "要么全填写所有字段,要么全不填写", |
| 120 | }; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | function generalCheck(value: KeyConfig): CheckResult { |
nothing calls this directly
no test coverage detected