Files
jiapuapp/utils/auth/password-policy.js
T

14 lines
370 B
JavaScript

export const PASSWORD_POLICY_MESSAGE =
"密码需为 8–32 位,并同时包含字母和数字";
export const validatePassword = (value) => {
const valid =
typeof value === "string" &&
value.length >= 8 &&
value.length <= 32 &&
/[A-Za-z]/.test(value) &&
/\d/.test(value);
return { valid, message: valid ? "" : PASSWORD_POLICY_MESSAGE };
};