feat: 黄金矿工容错
This commit is contained in:
parent
7c077e813a
commit
94f0496da0
|
|
@ -65,6 +65,10 @@ export function integer(value: any): number {
|
||||||
}
|
}
|
||||||
export function identifier(value: any): boolean { return typeof value === "string" && /^[A-Za-z0-9_:-]{1,100}$/.test(value); }
|
export function identifier(value: any): boolean { return typeof value === "string" && /^[A-Za-z0-9_:-]{1,100}$/.test(value); }
|
||||||
export function isProduct(value: any): boolean { return typeof value === "string" && /^gold_miner(?:_[A-Za-z0-9_-]+)?$/.test(value); }
|
export function isProduct(value: any): boolean { return typeof value === "string" && /^gold_miner(?:_[A-Za-z0-9_-]+)?$/.test(value); }
|
||||||
|
/** Match the six product IDs registered in WeChat; leave custom products unchanged. */
|
||||||
|
export function paymentProductId(value: string): string {
|
||||||
|
return value.replace(/^gold_miner_vip([0-5])$/, "gold_miner_$1");
|
||||||
|
}
|
||||||
export function parseObject(value: any): any {
|
export function parseObject(value: any): any {
|
||||||
if (typeof value === "string") { try { value = JSON.parse(value); } catch { reject("INVALID_INPUT", "请求参数不是合法的 JSON 字符串"); } }
|
if (typeof value === "string") { try { value = JSON.parse(value); } catch { reject("INVALID_INPUT", "请求参数不是合法的 JSON 字符串"); } }
|
||||||
if (!value || typeof value !== "object" || Array.isArray(value)) reject("INVALID_INPUT", "请求参数必须是 JSON 对象,不能是 null、数组或普通字符串");
|
if (!value || typeof value !== "object" || Array.isArray(value)) reject("INVALID_INPUT", "请求参数必须是 JSON 对象,不能是 null、数组或普通字符串");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user