MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / emptyOrAllCheck

Function emptyOrAllCheck

src/common/configuration.ts:96–121  ·  view source on GitHub ↗
(value: KeyConfig)

Source from the content-addressed store, hash-verified

94
95// 检查是否全空或全填写
96function 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
124function generalCheck(value: KeyConfig): CheckResult {

Callers

nothing calls this directly

Calls 3

getInvalidStringKeysFunction · 0.85
getEmptyKeysFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected