public static bool IsValid(string password)
{
// Минимум 8 символов
if (password.Length < 8)
return false;
// Хотя бы 1 заглавная буква
if (!Regex.IsMatch(password, @"[A-Z]"))
return false;
// Хотя бы 1 маленькая буква
if (!Regex.IsMatch(password, @"[a-z]"))
return false;
// Хотя бы 1 цифра
if (!Regex.IsMatch(password, @"\d"))
return false;
// Минимум 2 спецсимвола
if (Regex.Matches(password, @"[!$%@#&*?]").Count < 2)
return false;
// Нет одинаковых символов подряд
if (Regex.IsMatch(password, @"(.)\1"))
return false;
return true;
}