befly 3.74.1 → 3.74.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,7 @@ export const RUN_MODE_VALUES = ["development", "production"];
35
35
  // ==========================
36
36
 
37
37
  // 字段 input 可选值(统一用于 validator / checkTable / checkApi)
38
- export const FIELD_RULE_INPUT_TYPES = ["number", "integer", "string", "char", "array", "arrayNumber", "arrayInteger", "json", "jsonNumber", "jsonInteger", "regexp", "enum", "enumNumber", "enumInteger"];
38
+ export const FIELD_RULE_INPUT_TYPES = ["number", "integer", "string", "char", "array", "arrayNumber", "arrayInteger", "arrayObject", "json", "jsonNumber", "jsonInteger", "regexp", "enum", "enumNumber", "enumInteger"];
39
39
 
40
40
  // 字段 min/max 缺省值
41
41
  export const FIELD_RULE_DEFAULT_MIN = 0;
package/lib/validator.js CHANGED
@@ -90,6 +90,8 @@ function checkFieldValue(value, rule) {
90
90
  if (!isScalarArray(value)) return "必须是仅包含基础值的一层数组";
91
91
  if (input === "arrayNumber" && !value.every(isFiniteNumber)) return "数组元素必须是数字";
92
92
  if (input === "arrayInteger" && !value.every(isIntegerNumber)) return "数组元素必须是整数";
93
+ } else if (input === "arrayObject") {
94
+ if (!Array.isArray(value) || !value.every((item) => isPlainObject(item) && isFlatJson(item))) return "必须是对象成员仅包含基础值的一层数组";
93
95
  } else if (input === "json" || input === "jsonNumber" || input === "jsonInteger") {
94
96
  const kind = input === "json" ? "any" : input === "jsonNumber" ? "number" : "integer";
95
97
  if (!isFlatJson(value, kind)) return kind === "any" ? "必须是一层JSON对象或数组,成员只能是基础值" : `JSON值必须是${kind === "number" ? "数字" : "整数"}`;
@@ -128,7 +130,7 @@ function checkFieldValue(value, rule) {
128
130
  if (!values.includes(converted)) return "值不在枚举范围内";
129
131
  }
130
132
 
131
- if (input === "array" || input === "arrayNumber" || input === "arrayInteger") {
133
+ if (input === "array" || input === "arrayNumber" || input === "arrayInteger" || input === "arrayObject") {
132
134
  if (value.length < min) return `至少需要${min}个元素`;
133
135
  if (value.length > max) return `最多只能有${max}个元素`;
134
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.74.1",
3
+ "version": "3.74.3",
4
4
  "gitHead": "49c39d36695036e85fc64083cc43c1652fff96cb",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
package/utils/is.js CHANGED
@@ -347,10 +347,10 @@ export function isEmpty(value) {
347
347
 
348
348
  /**
349
349
  * 判断当前进程是否为主进程。
350
- * PM2 cluster 的实例 0 是主进程;未由 PM2 启动时视为主进程。
350
+ * bm2 的实例 0 是主进程;未由 bm2 启动时视为主进程。
351
351
  */
352
352
  export function isPrimaryProcess() {
353
- const instance = Bun.env.NODE_APP_INSTANCE;
353
+ const instance = Bun.env.BM2_APP_INSTANCE;
354
354
  return instance === "0" || instance === 0 || instance === undefined;
355
355
  }
356
356