You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/IoT.Shared/Application/Models/Users/RegisterModel.cs

42 lines
1.7 KiB

using Infrastructure.Web.DataAnnotations;
using Infrastructure.Web.Mvc;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace Application.Models
{
[Display(Name = "邮箱注册")]
public class RegisterModel
{
[Required(ErrorMessage = nameof(RequiredAttribute))]
[RegularExpression("^[a-zA-Z0-9]+$", ErrorMessage = "")]
[StringLength(30, MinimumLength = 5, ErrorMessage = "用户名长度为5-30")]
[Display(Name = "用户名")]
[Remote("UserNameNotUsed", "Account", ErrorMessage = "用户名已存在")]
public string UserName { get; set; }
[Required(ErrorMessage = nameof(RequiredAttribute))]
[StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度范围为{2}-{1}")]
[DataType(DataType.Password)]
[Display(Name = "登录密码")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "确认密码")]
[Compare("Password", ErrorMessage = "确认密码输入错误")]
public string ConfirmPassword { get; set; }
[Required(ErrorMessage = nameof(RequiredAttribute))]
[DataType(DataType.EmailAddress)]
[RegularExpression(@"^\w+@\w+\.\w+$", ErrorMessage = "邮箱格式错误")]
[Display(Name = "邮箱")]
[Remote("EmailNotUsed", "Account", ErrorMessage = "邮箱已占用")]
public string Email { get; set; }
[MustBeTrue(ErrorMessage = nameof(MustBeTrueAttribute))]
[AdditionalMetadata("用户服务协议", "/")]
[Display(Name = "我阅读并同意")]
[UIHint("MustBeTrue")]
public bool AgreeWith { get; set; }
}
}