Is there a method to implement a required attribute to my virtualPassword
property, but with the condition if Password
in null?
Here’s my code.
[DataType(DataType.Password)]
[LocalizedDisplayName("UserPassword", NameResourceType = typeof(Languages.Names))]
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(Languages.Validations))]
public string Password { get; set; }
private string _virtualPassword = null;
[NotMapped]
[DataType(DataType.Password)]
[LocalizedDisplayName("UserPassword", NameResourceType = typeof(Languages.Names))]
[StringLength(12, MinimumLength = 6, ErrorMessageResourceName = "StringLengthBetween", ErrorMessageResourceType = typeof(Languages.Validations))]
public virtual string virtualPassword { get { return _virtualPassword; } set { _virtualPassword = value; } }