Skip to content

Commit 62df82d

Browse files
committed
Use ValidationHelper for email regex
1 parent 3f4b3ef commit 62df82d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Models/Account/RegisterViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System.Collections.Generic;
22
using System.ComponentModel.DataAnnotations;
3-
using System.Text.RegularExpressions;
43
using Abp.Auditing;
54
using Abp.Authorization.Users;
65
using Abp.Extensions;
6+
using AbpCompanyName.AbpProjectName.Validation;
77

88
namespace AbpCompanyName.AbpProjectName.Web.Models.Account
99
{
@@ -37,8 +37,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
3737
{
3838
if (!UserName.IsNullOrEmpty())
3939
{
40-
var emailRegex = new Regex(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
41-
if (!UserName.Equals(EmailAddress) && emailRegex.IsMatch(UserName))
40+
if (!UserName.Equals(EmailAddress) && ValidationHelper.IsEmail(UserName))
4241
{
4342
yield return new ValidationResult("Username cannot be an email address unless it's the same as your email address!");
4443
}

0 commit comments

Comments
 (0)