Files
TechHelper/Entities/DTO/User/UserForRegistrationDto.cs
SpecialX ac900159ba
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
重构项目结构,移除Assignment相关功能,优化Submission模块
2025-10-09 18:57:28 +08:00

44 lines
1.9 KiB
C#

using Entities.Contracts;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.DTO
{
public class UserForRegistrationDto
{
[Required(ErrorMessage = "姓名是必填项。")]
[StringLength(50, MinimumLength = 2, ErrorMessage = "姓名长度必须在 2 到 50 个字符之间。")]
public string DisplayName { get; set; }
[Required(ErrorMessage = "电子邮件是必填项。")]
[EmailAddress(ErrorMessage = "电子邮件格式不正确。")]
public string Email { get; set; }
[Required(ErrorMessage = "密码是必填项。")]
[StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度至少为 6 个字符。")]
[RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&.])[A-Za-z\d@$!%*?&.]{6,}$",
ErrorMessage = " @$!%*?&. ")]
public string Password { get; set; }
[Compare(nameof(Password), ErrorMessage = "密码和确认密码不匹配。")]
[Required(ErrorMessage = "确认密码是必填项。")]
public string ConfirmPassword { get; set; }
[Required(ErrorMessage = "至少选择一个角色。")]
public UserRoles Roles { get; set; } = UserRoles.Student;
[Phone(ErrorMessage = "电话号码格式不正确。")]
[StringLength(11, MinimumLength = 11, ErrorMessage = "电话号码必须是 11 位数字。")]
public string? PhoneNumber { get; set; }
[StringLength(200, ErrorMessage = "家庭住址不能超过 200 个字符。")]
public string? HomeAddress { get; set; }
public RegisterUserToClassDto RegisterUserToClassDto { get; set; } = new RegisterUserToClassDto();
}
}