newDemoAvaloniaVal/AvaloniaValidation/Client.cs

51 lines
1.5 KiB
C#
Raw Normal View History

2025-01-22 13:30:15 +00:00
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("Password must be at least 6 characters long");
}
if (!password.Any(char.IsDigit))
{
throw new ArgumentException("Password must contain at least one digit");
}
if (!password.Any(char.IsUpper) || !password.Any(char.IsLower))
{
throw new ArgumentException("Password must contain at least one uppercase letter");
}
var regex = new Regex(@"[!@#$%^&*()_+{}|{}\\|]");
if (!regex.IsMatch(password))
{
throw new ArgumentException("Password must contain at least one uppercase letter");
}
}
}