public static void Main()
string field1 = ExtractFieldAndDeterminateType("The Email field is required.", out Type type1);
Console.WriteLine($"Field is: {field1} and Type is: {type1}");
string field2 = ExtractFieldAndDeterminateType("The Username field is required.", out Type type2);
Console.WriteLine($"Field is: {field2} and Type is: {type2}");
string field3 = ExtractFieldAndDeterminateType("The InsertDate field is not a valid date.", out Type type3);
Console.WriteLine($"Field is: {field3} and Type is: {type3}");
string field4 = ExtractFieldAndDeterminateType("Age should be between 1 and 99.", out Type type4);
Console.WriteLine($"Field is: {field4} and Type is: {type4}");
public static string ExtractFieldAndDeterminateType(string input, out Type type)
string required = "The {0} field is required.";
string date = "The {0} field is not a valid date.";
string range = "{0} should be between {1} and {2}.";
string extractedField = string.Empty;
if (isRequired) type = Type.Error;
if (isDate) type = Type.Date;
if (isRange) type = Type.Range;