public ActionResult Index(ManuallyRunningTheValidatorModel model)
 {
   var settings = new PasswordValidationSettings();
   settings.MinimumPasswordLength = 6;
   settings.NeedsLetter = true;
   settings.NeedsNumber = true;
   settings.StandardWordLists.Add(StandardWordList.MostCommon500Passwords);
   var validator = new Validator(settings);
   bool result = validator.Validate(model.Password);
   model.IsPasswordAcceptable = result;
   return View("ManuallyRunningTheValidator", model);
 }
コード例 #2
0
    static void Main(string[] args)
    {
      Console.WriteLine("Please enter a password to see if it could be valid.");
      Console.Write("> ");
      string password = Console.ReadLine();

      Validator validator = new Validator();
      bool result = validator.Validate(password);
      if (result)
        Console.WriteLine("This password can be used.");
      else
        Console.WriteLine("This password failed the validation.");

      Console.WriteLine("Press a key to exit the console application.");
      Console.ReadKey();
    }