public static ValidateTarget <TCollection> IsEmptyByEnumeration <TCollection>([ValidatedNotNull] this ValidateTarget <TCollection> target, Func <string> getErrorMessage = null) where TCollection : IEnumerable { if (target.Value == null || CollectionProxy <TCollection> .GetCountByEnumeration(target.Value, 1) != 0) { ExceptionFactory.ThrowException(target.Traits.GenericFailureExceptionType, getErrorMessage != null ? getErrorMessage.Invoke() : ErrorMessageFactory.ShouldBeEmpty(target)); } return(target); }
public static ValidateTarget <string> IsEmpty([ValidatedNotNull] this ValidateTarget <string> target, Func <string> getErrorMessage = null) { if (target.Value == null || target.Value.Length != 0) { ExceptionFactory.ThrowException(target.Traits.GenericFailureExceptionType, getErrorMessage != null ? getErrorMessage.Invoke() : ErrorMessageFactory.ShouldBeEmpty(target)); } return(target); }