0

I'm using asp.net mvc core for my project. In the registration form i got a problem with validation.

1) Password ask for special symbol (like @+*! etc)

2) The validation message is not correct (Passwords must have at least one non alphanumeric character. Passwords must have at least one lowercase ('a'-'z')).

How can i change requiments of special symbol to password and where can i change validation error?

I've found the answer for asp.net mvc 5 with config file, but asp.net core doesn't have any config files for this.

Sergey Bakotin
  • 373
  • 1
  • 3
  • 15
  • 3
    Possible duplicate of [asp.net core mvc password validators](https://stackoverflow.com/questions/38172195/asp-net-core-mvc-password-validators) – Josh Mein Apr 05 '18 at 12:45
  • @JoshMein: This is about the `ErrorDescriber` I think, which is separate from the validation rules themselves. Sounds like he already has the rule he wants, but wants to change the message it has. – Charles Apr 05 '18 at 14:32
  • @Charles He said he wants to change the requirements of special symbols and also change the message. If you dont think the duplicate covers all of his question, you are free to answer here as well. – Josh Mein Apr 05 '18 at 16:04

1 Answers1

1

First you're going to need to make a custom IdentityErrorDescriber.

Then you'll need to add it like so:

services.AddIdentity<ApplicationUser, IdentityRole>()
    .AddErrorDescriber<CustomIdentityErrorDescriber>();

They're a lot of examples of this for localization that you can find.

Charles
  • 640
  • 5
  • 21