/// <summary> /// Determines whether [is email address] [the specified rule]. /// </summary> /// <param name="rule">The rule.</param> /// <param name="value">The value.</param> /// <returns><c>true</c> if [is email address] [the specified rule]; otherwise, <c>false</c>.</returns> private static bool IsEmailAddress(Rule rule, string value) { try { return string.IsNullOrEmpty(value) || EmailAddress.IsMatch(value); } catch (Exception ex) { Debug.WriteLine(ex.Message); throw; } }
/// <summary> /// Determines whether [is date time] [the specified rule]. /// </summary> /// <param name="rule">The rule.</param> /// <param name="value">The value.</param> /// <returns><c>true</c> if [is date time] [the specified rule]; otherwise, <c>false</c>.</returns> private static bool IsDateTime(Rule rule, string value) { if (string.IsNullOrEmpty(value)) return true; value = value.Trim(); if (ShortDate.Match(value).Success) { value = value.Substring(0, 2) + "/" + value.Substring(2, 2) + "/" + value.Substring(4, 2); } if (LongDate.Match(value).Success) { value = value.Substring(0, 2) + "/" + value.Substring(2, 2) + "/" + value.Substring(4, 4); } DateTime d; return DateTime.TryParse(value, out d); }
/// <summary> /// Determines whether [is alpha numeric] [the specified rule]. /// </summary> /// <param name="rule">The rule.</param> /// <param name="value">The value.</param> /// <returns><c>true</c> if [is alpha numeric] [the specified rule]; otherwise, <c>false</c>.</returns> private static bool IsAlphaNumeric(Rule rule, string value) { return string.IsNullOrEmpty(value) || Numeric.IsMatch(value); }
/// <summary> /// Musts the end in COM. /// </summary> /// <param name="rule">The rule.</param> /// <param name="val">The value.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> private bool MustEndInCom(Rule rule, string val) { return string.IsNullOrEmpty(val) || val.EndsWith("com"); }
/// <summary> /// Determines whether [is alpha only] [the specified rule]. /// </summary> /// <param name="rule">The rule.</param> /// <param name="value">The value.</param> /// <returns><c>true</c> if [is alpha only] [the specified rule]; otherwise, <c>false</c>.</returns> private static bool IsAlphaOnly(Rule rule, string value) { return string.IsNullOrEmpty(value) || AlphaOnly.IsMatch(value); }