using PrivaPub.ClientModels.Resources; using System.ComponentModel.DataAnnotations; namespace PrivaPub.ClientModels { [AtLeastOneProperty(nameof(UserName), nameof(Email), ErrorMessageResourceName = "AtLeastOneProperty", ErrorMessageResourceType = typeof(ErrorsResource))] public class PasswordRecoveryForm { [Display(Name = "UserName", ResourceType = typeof(FieldsNameResource)), MinLength(3, ErrorMessageResourceName = "MinLength", ErrorMessageResourceType = typeof(ErrorsResource))] public string UserName { get; set; } [Display(Name = "Email", ResourceType = typeof(FieldsNameResource)), DataType(DataType.EmailAddress), MinLength(3, ErrorMessageResourceName = "MinLength", ErrorMessageResourceType = typeof(ErrorsResource)), EmailAddress(ErrorMessageResourceName = "InvalidEmail", ErrorMessageResourceType = typeof(ErrorsResource))] public string Email { get; set; } public bool IsUsernameDisabled => !string.IsNullOrEmpty(Email); public bool IsEmailDisabled => !string.IsNullOrEmpty(UserName); } }