全球化与本地化
This commit is contained in:
1 parent
6fef1a9ea0
commit
77b9f64039
15 files changed
+649
-7
No files matched your search
@@ -3,19 +3,20 @@ using HelloShop.IdentityService.Entities;
|
||||
using HelloShop.IdentityService.EntityFrameworks;
|
||||
using HelloShop.IdentityService.Models.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace HelloShop.IdentityService.Validations.Users;
|
||||
|
||||
public class UserCreateRequestValidator : AbstractValidator<UserCreateRequest>
|
||||
{
|
||||
public UserCreateRequestValidator(IdentityServiceDbContext dbContext)
|
||||
public UserCreateRequestValidator(IdentityServiceDbContext dbContext,IStringLocalizer<UserCreateRequest> localizer )
|
||||
{
|
||||
RuleFor(m => m.UserName).NotNull().NotEmpty().Length(8, 16).Matches("^[a-zA-Z]+$");
|
||||
|
||||
RuleFor(m => m.PhoneNumber).NotNull().NotEmpty().Length(11).Matches(@"^1\d{10}$").Must((phoneNumber) =>
|
||||
{
|
||||
return !dbContext.Set<User>().Any(e => e.PhoneNumber == phoneNumber);
|
||||
});
|
||||
}).WithMessage(localizer["PhoneNumberAlreadyExists"]);
|
||||
|
||||
RuleFor(m => m.Password).NotNull().NotEmpty().Length(8, 16);
|
||||
|
||||
|
||||
Reference in new issue
Block a user