public static ValidateTarget <TValue> IsTrue <TValue>([ValidatedNotNull] this ValidateTarget <TValue> target, Func <bool> assertion, Func <string> getErrorMessage = null) { if (assertion == null) { throw new ArgumentNullException(nameof(assertion)); } if (!assertion.Invoke()) { ExceptionFactory.ThrowException(target.Traits.GenericFailureExceptionType, getErrorMessage != null ? getErrorMessage.Invoke() : ErrorMessageFactory.ShouldBeTrueOnCustomAssertion(target)); } return(target); }
public static void IsTrue <TException>(bool isValid, Func <string> getErrorMessage = null) where TException : Exception { if (isValid) { return; } ExceptionFactory.ThrowException(typeof(TException), getErrorMessage != null ? getErrorMessage.Invoke() : ErrorMessageFactory.ShouldBeTrueOnCustomAssertion()); }