//#region src/components/systemSettings/registry/utils/validators.ts
/**
* 验证器工具函数
*/
/**
* 创建带前缀的应用标识符验证器
* 用于验证设置项的键格式
*/
const createPrefixedAppIdentifierValidator = (sectionCode) => {
	return (_, value) => {
		if (!value) return Promise.resolve();
		const expectedPrefix = `${sectionCode}.`;
		if (!value.startsWith(expectedPrefix)) return Promise.reject(/* @__PURE__ */ new Error(`键必须以 "${expectedPrefix}" 开头`));
		const remainingPart = value.substring(expectedPrefix.length);
		if (!remainingPart) return Promise.reject(/* @__PURE__ */ new Error("键不能只包含前缀"));
		if (!/^[a-z0-9._]+$/.test(remainingPart)) return Promise.reject(/* @__PURE__ */ new Error("键只能包含小写字母、数字、点、下划线"));
		if (remainingPart.startsWith(".") || remainingPart.startsWith("_") || remainingPart.endsWith(".") || remainingPart.endsWith("_")) return Promise.reject(/* @__PURE__ */ new Error("键不能以点或下划线开头或结尾"));
		if (remainingPart.includes("..") || remainingPart.includes("__") || remainingPart.includes("._") || remainingPart.includes("_.")) return Promise.reject(/* @__PURE__ */ new Error("键不能包含连续的点或下划线"));
		return Promise.resolve();
	};
};
//#endregion
exports.createPrefixedAppIdentifierValidator = createPrefixedAppIdentifierValidator;
