newDemoAvaloniaVal/AvaloniaValidation/Client.cs
2025-01-28 22:01:04 +03:00

51 lines
1.6 KiB
C#

using System;
using System.Linq;
using System.Runtime.InteropServices.JavaScript;
using System.Text.RegularExpressions;
namespace AvaloniaValidation;
public class Client
{
public int Id { get; set; }
public string FIO { get; set; }
public string Gender { get; set; }
public string Role { get; set; }
public string email { get; set; }
public string phone { get; set; }
public string napravlenie { get; set; }
public string meropriyatie { get; set; }
private string _Password { get; set; }
public string confirmPassword { get; set; }
public string Password
{
get => _Password;
set
{
ValidationPassword(value);
_Password = value;
}
}
private void ValidationPassword(string password)
{
if (password.Length < 6)
{
throw new ArgumentException("Парольдолжен быть длинее 6 символов");
}
if (!password.Any(char.IsDigit))
{
throw new ArgumentException("Пароль должен содержать хотя бы 1 цифру");
}
if (!password.Any(char.IsUpper) || !password.Any(char.IsLower))
{
throw new ArgumentException("Пароль должен содержать хотя бы 1 заглавную букву");
}
var regex = new Regex(@"[!@#$%^&*()_+{}|{}\\|]");
if (!regex.IsMatch(password))
{
throw new ArgumentException("Пароль должен содержать хотя бы 1 специальный символ");
}
}
}