using System.ComponentModel.DataAnnotations; using FluentValidation; namespace DS.WMS.Core.System.Dtos; /// /// 修改密码实体 /// public class ChangePasswordReq { // /// // /// 用户Id // /// // public string UserId { get; set; } /// /// 旧密码 /// public string OldPassword { get; set; } /// /// 新密码 /// [RegularExpression(pattern:@"^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$",ErrorMessage ="密码至少要包含8个字符,同时包含至少一个大写字母、一个小写字母、一个数字和一个特殊字符")] public string NewPassword { get; set; } /// /// 确认密码 /// public string ConfirmPassword { get; set; } } /// /// 验证 /// public class ChangePasswordInputValidator : AbstractValidator { /// /// 构造函数 /// public ChangePasswordInputValidator() { // this.RuleFor(o => o.UserId) // .NotEmpty().WithName("用户Id"); this.RuleFor(o => o.OldPassword) .NotEmpty().WithName("旧密码"); this.RuleFor(o => o.NewPassword) .NotEmpty().WithName("新密码"); this.RuleFor(o => o.ConfirmPassword) .NotEmpty().WithName("确认密码"); } }