Files
atlas-seller-kit/apps/web/src/utils/validators.ts
T
2026-09-03 13:11:38 +08:00

10 lines
401 B
TypeScript

import type { Rule } from 'antd/es/form';
/** 邮箱格式校验:仅在非空时校验,避免与 required 规则在空值时同时报错(antd v6 行为) */
export const emailFormatRule: Rule = {
validator: (_, value: string) =>
!value || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
? Promise.resolve()
: Promise.reject(new Error('邮箱格式不正确')),
};