fix: 优化表单检测逻辑

This commit is contained in:
ZhuRui
2026-08-06 09:23:18 +08:00
parent e3bd35e154
commit 8c7e8f807c
10 changed files with 326 additions and 135 deletions
+11
View File
@@ -27,6 +27,12 @@ export const LOGIN_PASSWORD_REGEX = /^(?=.*[A-Za-z])(?=.*\d)[\w!@#$%^&*()_+\-=]{
*/
export const REAL_NAME_REGEX = /^[\u4e00-\u9fa5A-Za-z0-9·]{1,8}$/;
/**
* 图片 MIME 类型前缀
* - 用于上传前校验文件是否为图片
*/
export const IMAGE_TYPE_REGEX = /^image\//;
// ============================================================
// 校验函数
// ============================================================
@@ -45,3 +51,8 @@ export function isValidPassword(value: unknown): boolean {
export function isValidRealName(value: unknown): boolean {
return typeof value === 'string' && value.length > 0 && REAL_NAME_REGEX.test(value);
}
/** 校验文件是否为图片类型 */
export function isImageFile(file: { type: string }): boolean {
return IMAGE_TYPE_REGEX.test(file.type);
}