public static void ValidateNotSupplied(string s, ClientExDetail detail) { if (!string.IsNullOrWhiteSpace(s)) { throw detail.Instance(); } }
internal static string ValidateMustMatchIfBothSupplied(string s1, string s2, ClientExDetail detail) { // s1 | s2 || result // ---- | ---- || -------------- // null | null || valid, null s2 // null | y || valid, y s2 // x | null || valid, x s1 // x | x || valid, x s1 // x | y || invalid s1 = EmptyAsNull(s1); s2 = EmptyAsNull(s2); if (s1 == null) { return(s2); // s2 can be either null or y } // x / null or x / x if (s2 == null || s1.Equals(s2)) { return(s1); } throw detail.Instance(); }