Skip to content
On this page

checkEmail

邮箱校验函数

使用方法

ts
import { checkEmail } from '@kanjianmusic/fn';

// 默认校验规则 /^[a-zA-Z0-9]+([+-_.][a-zA-Z0-9]+)*@([a-zA-Z0-9]+\.)+[A-Za-zd]{2,5}$/
checkEmail('[email protected]'); // true
checkEmail('[email protected]'); // true
checkEmail('[email protected]'); // false
checkEmail('[email protected]'); // true
checkEmail('[email protected]'); // false
checkEmail('zhangsan@kanjian+.com'); // false

// 自定义规则
checkEmail('[email protected]', /^[a-zA-Z0-9]+@([a-zA-Z0-9]+\.)+com$/) // true
checkEmail('[email protected]', /^[a-zA-Z0-9]+@([a-zA-Z0-9]+\.)+com$/) // false