wendajia/frontend/src/taobaoId.js

12 lines
381 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const TAOBAO_ID_HINT = "请输入2-64位淘宝ID,支持中文、英文字母、数字、下划线、点和短横线";
const TAOBAO_ID_PATTERN = /^[\p{Script=Han}A-Za-z0-9_.-]{2,64}$/u;
export function normalizeTaobaoId(value) {
return String(value || "").trim();
}
export function isValidTaobaoId(value) {
return TAOBAO_ID_PATTERN.test(normalizeTaobaoId(value));
}