merchant onboarding process completed

This commit is contained in:
2025-08-06 16:11:02 +05:30
parent f90d1f0c57
commit 1a27e282e3
22 changed files with 768 additions and 19 deletions

View File

@ -0,0 +1,92 @@
namespace Singer_Hexdive.Validations
{
public class FieldValidators
{
public static string EnsureNotNullOrEmpty(string value, string fieldName)
{
if (string.IsNullOrWhiteSpace(value))
throw new ArgumentException($"{fieldName} cannot be empty.", fieldName);
else
{
return value;
}
}
public static int EnsureNotLessZero(int value, string fieldName)
{
if (value < 0)
throw new ArgumentException($"{fieldName} cannot be less than zero.", fieldName);
else
{
return value;
}
}
public static decimal EnsureIsMin(decimal value, int minValue, string fieldName)
{
if (value > minValue)
throw new ArgumentException($"{fieldName} cannot be less than {minValue}.", fieldName);
else
{
return value;
}
}
public static decimal EnsureIsMax(decimal value, int maxValue, string fieldName)
{
if (value < maxValue)
throw new ArgumentException($"{fieldName} cannot be less than {maxValue}.", fieldName);
else
{
return value;
}
}
//public static bool IsValidEmail(string email, string fieldName)
//{
// if (string.IsNullOrWhiteSpace(email))
// throw new ArgumentException($"{fieldName} cannot be empty.", fieldName);
// try
// {
// var addr = new System.Net.Mail.MailAddress(email);
// return addr.Address == email;
// }
// catch
// {
// throw new ArgumentException($"{fieldName} is not a valid .", fieldName);
// }
//}
public static string IsValidPhoneNumber(string phoneNumber, string fieldName)
{
if (string.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentException($"{fieldName} cannot be empty.", fieldName);
if (!phoneNumber.All(char.IsDigit) || phoneNumber.Length != 10)
throw new ArgumentException($"{fieldName} must be exactly 10 digits.", fieldName);
return phoneNumber;
}
public static string EnsureValidEmail(string email, string fieldName)
{
if (string.IsNullOrWhiteSpace(email))
throw new ArgumentException($"{fieldName} cannot be empty.", fieldName);
try
{
var addr = new System.Net.Mail.MailAddress(email);
if (addr.Address != email)
throw new ArgumentException($"{fieldName} is not a valid email address.", fieldName);
}
catch
{
throw new ArgumentException($"{fieldName} is not a valid email address.", fieldName);
}
return email;
}
}
}