Files
WCS/Cowain.Base/ViewModels/UserViewModel.cs

41 lines
1006 B
C#
Raw Normal View History

using CommunityToolkit.Mvvm.ComponentModel;
using System.ComponentModel.DataAnnotations;
using MinLengthAttribute = Cowain.Base.Attributes.MinLengthAttribute;
namespace Cowain.Base.ViewModels;
public partial class UserViewModel : ObservableValidator
{
[ObservableProperty]
private int _id;
/// <summary>
/// 角色名称
/// </summary>
[ObservableProperty]
[NotifyDataErrorInfo]
[MinLength(2, "Errors.MinLength")]
private string? _name;
[ObservableProperty]
[NotifyDataErrorInfo]
[MinLength(4, "Errors.MinLength")]
private string? _userNumber;
[ObservableProperty]
private string? _phone;
[ObservableProperty]
private int _roleId;
[ObservableProperty]
private string? _roleName;
[ObservableProperty]
[NotifyDataErrorInfo]
[Required(ErrorMessage = "必填")]// 必填项目
private string? _sex;
[ObservableProperty]
private string? _password;
[ObservableProperty]
private bool _isValid;
}