Put Validation on Asp Net MVC Identity

-2

I tried to locate this question in the forum and could not find it. I have an MVC Asp Net application that uses to login the Entity Framework with Identity. My client registration works perfectly, but I am not able to validate two fields: Username and Login. I tried to locate where they are called, but from what I read on the net so far, it gets "encapsulated" and I could not place the validations on them. I would like to put a validation like this on them:

[Required]
    [StringLength(10, MinimumLength = 6)]
    public string Senha { get; set; }

The problem is that I am not able to find Username and Login. I could not find the AccountViewModels.cs that indicated me on the net. Can someone help me please? I would like to validate the Username and Login fields so that it is not possible to save the registration with them blank, as I did not find their location, I can not validate and the easiest way I found was as I reported in the code above. >     

asked by anonymous 22.02.2018 / 03:46

1 answer

0

To register a user, identity in aspnet mvc 5 uses the RegisterViewModel class that is in the AccountViewModels.cs file within the Models .

public class RegisterViewModel
{
    [Required]
    [EmailAddress]
    [Display(Name = "Email")]
    public string Email { get; set; }

    [Required]
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }

    [DataType(DataType.Password)]
    [Display(Name = "Confirm password")]
    [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
    public string ConfirmPassword { get; set; }
}

This is the class that receives the email, password, and password confirmation from the log screen. Here you can customize the validations at will.

    
22.02.2018 / 13:31