From 51ec5564a0ede45b17e61b7f808cbeca0abaeaa3 Mon Sep 17 00:00:00 2001
From: ​
Date: Thu, 1 Jan 1970 00:00:00 +0000
Subject: clone customer

---
 clone_customer/CloneCustomer/Validator.cs | 81 +++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 clone_customer/CloneCustomer/Validator.cs

(limited to 'clone_customer/CloneCustomer/Validator.cs')

diff --git a/clone_customer/CloneCustomer/Validator.cs b/clone_customer/CloneCustomer/Validator.cs
new file mode 100644
index 0000000..ddc01b6
--- /dev/null
+++ b/clone_customer/CloneCustomer/Validator.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace CustomerMaintenance
+{
+	public static class Validator
+	{
+		private static string lineEnd = "\n";
+
+		public static string LineEnd
+		{
+			get
+			{
+				return lineEnd;
+			}
+			set
+			{
+				lineEnd = value;
+			}
+		}
+
+		public static string IsPresent(string value, string name)
+		{
+			string msg = "";
+			if (value == "")
+			{
+				msg += name + " is a required field." + LineEnd;
+			}
+			return msg;
+		}
+
+		public static string IsDecimal(string value, string name)
+		{
+			string msg = "";
+			if (!Decimal.TryParse(value, out _))
+			{
+				msg += name + " must be a valid decimal value." + LineEnd;
+			}
+			return msg;
+		}
+
+		 public static string IsInt32(string value, string name)
+		{
+			string msg = "";
+			if (!Int32.TryParse(value, out _))
+			{
+				msg += name + " must be a valid integer value." + LineEnd;
+			}
+			return msg;
+		}
+
+		public static string IsWithinRange(string value, string name, decimal min,
+			decimal max)
+		{
+			string msg = "";
+			if (Decimal.TryParse(value, out decimal number))
+			{
+				if (number < min || number > max)
+				{
+					msg += name + " must be between " + min + " and " + max + "." + LineEnd;
+				}
+			}
+			return msg;
+		}
+
+		public static string IsValidEmail(string value, string name)
+		{
+			string msg = "";
+			if (value.IndexOf("@") == -1 ||
+				 value.IndexOf(".") == -1)
+			{
+				msg += name + " must be a valid email address." + LineEnd;
+			}
+			return msg;
+		}
+	}
+}
-- 
cgit 1.4.1