public static IValidationTarget <TType> IsSize <TType>(this IValidationTarget <TType> target, int expected) where TType : ICollection { return(target.And(new DefaultValidationPredicate <TType>(v => v.Count == expected, ExceptionMessages.CollectionsSizeIsFailed.Inject( expected, target.Value.Count)))); }
public static IValidationTarget <sbyte> IsMaximumValue(this IValidationTarget <sbyte> target) { return(target.And(new DefaultValidationPredicate <sbyte>(v => v == sbyte.MaxValue, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, sbyte.MaxValue)))); }
public static IValidationTarget <decimal> IsMaximumValue(this IValidationTarget <decimal> target) { return(target.And(new DefaultValidationPredicate <decimal>(v => Math.Abs(v - decimal.MaxValue) < m_comparisionTolerance, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, decimal.MaxValue)))); }
public static IValidationTarget <long> IsNotMinimumValue(this IValidationTarget <long> target) { return(target.And(new DefaultValidationPredicate <long>(v => v != long.MinValue, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, long.MinValue)))); }
public static IValidationTarget <float> IsNotMinimumValue(this IValidationTarget <float> target) { return(target.And(new OutOfRangeValidationPredicate <float>(v => Math.Abs(v - float.MinValue) > m_comparisionTolerance, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, float.MinValue)))); }
public static IValidationTarget <DateTime> IsAfterOrSameAsToday(this IValidationTarget <DateTime> target) { return(target.And(new OutOfRangeValidationPredicate <DateTime>(v => v.Date >= DateTime.Today.Date, ExceptionMessages.DateTimeIsAfterOrSameAsFailed.Inject( target.Value, DateTime.Now.Date)))); }
public static IValidationTarget <DateTime> IsBeforeUtcNow(this IValidationTarget <DateTime> target) { return(target.And(new OutOfRangeValidationPredicate <DateTime>(v => v < DateTime.UtcNow, ExceptionMessages.DateTimeIsBeforeFailed.Inject( target.Value, DateTime.UtcNow)))); }
public static IValidationTarget <DateTime> IsNotEqualToNow(this IValidationTarget <DateTime> target) { return(target.And(new DefaultValidationPredicate <DateTime>(v => v != DateTime.Now, ExceptionMessages.DateTimeIsNotSameAsFailed.Inject( target.Value, DateTime.Now)))); }
public static IValidationTarget <DateTime> IsAfterOrSame(this IValidationTarget <DateTime> target, DateTime dateTime) { return(target.And(new OutOfRangeValidationPredicate <DateTime>(v => v >= dateTime, ExceptionMessages.DateTimeIsAfterOrSameAsFailed.Inject( target.Value, dateTime)))); }
public static IValidationTarget <int> IsNotMaximumValue(this IValidationTarget <int> target) { return(target.And(new DefaultValidationPredicate <int>(v => v != int.MaxValue, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, int.MaxValue)))); }
public static IValidationTarget <DateTime> IsEqual(this IValidationTarget <DateTime> target, DateTime dateTime) { return(target.And(new DefaultValidationPredicate <DateTime>(v => v == dateTime, ExceptionMessages.DateTimeIsSameAsFailed.Inject( target.Value, dateTime)))); }
public static IValidationTarget <double> IsNotMinimumValue(this IValidationTarget <double> target) { return(target.And(new DefaultValidationPredicate <double>(v => Math.Abs(v - double.MinValue) > m_comparisionTolerance, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, double.MinValue)))); }
public static IValidationTarget <TimeSpan> IsNotMaximumValue(this IValidationTarget <TimeSpan> target) { return(target.And(new OutOfRangeValidationPredicate <TimeSpan>(v => v != TimeSpan.MaxValue, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, TimeSpan.MaxValue)))); }
public static IValidationTarget <TimeSpan> IsEqual(this IValidationTarget <TimeSpan> target, TimeSpan timeSpan) { return(target.And(new DefaultValidationPredicate <TimeSpan>(v => v == timeSpan, ExceptionMessages.DateTimeIsSameAsFailed.Inject( target.Value, timeSpan)))); }
public static IValidationTarget <TimeSpan> IsBeforeOrSame(this IValidationTarget <TimeSpan> target, TimeSpan timeSpan) { return(target.And(new OutOfRangeValidationPredicate <TimeSpan>(v => v <= timeSpan, ExceptionMessages.DateTimeIsBeforeOrSameAsFailed.Inject( target.Value, timeSpan)))); }
public static IValidationTarget <ICollection <TType> > DoesNotContainValue <TType>( this IValidationTarget <ICollection <TType> > target, TType value) { return(target.And(new DefaultValidationPredicate <ICollection <TType> >(v => !v.Contains(value), ExceptionMessages.CollectionsDoesNotContainValueFailed))); }
public static IValidationTarget <IDictionary <TKey, TType> > DoesNotContainKey <TKey, TType>( this IValidationTarget <IDictionary <TKey, TType> > target, Func <TKey, bool> predicate) { return(target.And(new DefaultValidationPredicate <IDictionary <TKey, TType> >(v => !v.Keys.All(predicate), ExceptionMessages.DictionaryNotAnyKeyFailed))); }
public static IValidationTarget <DateTimeOffset> IsAfterOrSameAsUtcNow(this IValidationTarget <DateTimeOffset> target) { return(target.And(new OutOfRangeValidationPredicate <DateTimeOffset>(v => v >= DateTimeOffset.UtcNow, ExceptionMessages.DateTimeIsAfterOrSameAsFailed.Inject( target.Value, DateTimeOffset.UtcNow)))); }
public static IValidationTarget <DateTimeOffset> IsBeforeToday(this IValidationTarget <DateTimeOffset> target) { return(target.And(new OutOfRangeValidationPredicate <DateTimeOffset>(v => v.Date < DateTimeOffset.Now.Date, ExceptionMessages.DateTimeIsBeforeFailed.Inject( target.Value, DateTimeOffset.Now.Date)))); }
public static IValidationTarget <DateTimeOffset> IsNotEqualToToday(this IValidationTarget <DateTimeOffset> target) { return(target.And(new DefaultValidationPredicate <DateTimeOffset>(v => v.Date != DateTimeOffset.Now.Date, ExceptionMessages.DateTimeIsNotSameAsFailed.Inject( target.Value, DateTimeOffset.Now.Date)))); }
public static IValidationTarget <DateTimeOffset> IsNotMinimumValue(this IValidationTarget <DateTimeOffset> target) { return(target.And(new OutOfRangeValidationPredicate <DateTimeOffset>(v => v != DateTimeOffset.MinValue, ExceptionMessages.NumbersIsMaxValueFailed.Inject( target.Value, DateTimeOffset.MinValue)))); }
public static IValidationTarget <DateTimeOffset> IsNotEqual(this IValidationTarget <DateTimeOffset> target, DateTimeOffset offset) { return(target.And(new DefaultValidationPredicate <DateTimeOffset>(v => v != offset, ExceptionMessages.DateTimeIsNotSameAsFailed.Inject( target.Value, offset)))); }
public static IValidationTarget <DateTimeOffset> IsEqualToUtcNow(this IValidationTarget <DateTimeOffset> target) { return(target.And(new DefaultValidationPredicate <DateTimeOffset>(v => v == DateTimeOffset.UtcNow, ExceptionMessages.DateTimeIsSameAsFailed.Inject( target.Value, DateTimeOffset.UtcNow)))); }
public static IValidationTarget <DateTimeOffset> IsBeforeOrSame(this IValidationTarget <DateTimeOffset> target, DateTimeOffset offset) { return(target.And(new OutOfRangeValidationPredicate <DateTimeOffset>(v => v <= offset, ExceptionMessages.DateTimeIsBeforeOrSameAsFailed.Inject( target.Value, offset)))); }
public static IValidationTarget <IDictionary <TKey, TType> > DoesNotContainValue <TKey, TType>( this IValidationTarget <IDictionary <TKey, TType> > target, Func <TType, bool> predicate) { return(target.And(new DefaultValidationPredicate <IDictionary <TKey, TType> >(v => !v.Values.Any(predicate), ExceptionMessages.CollectionsNotAnyFailed))); }
public static IValidationTarget <string> IsEqualTo(this IValidationTarget <string> target, string expected, StringComparison?comparison = null) { return(target.And(new DefaultValidationPredicate <string>(v => StringEquals(v, expected, comparison), ExceptionMessages.StringsIsEqualToFailed .Inject(target.Value, expected)))); }
public static IValidationTarget <IDictionary <TKey, TType> > ContainsValue <TKey, TType>( this IValidationTarget <IDictionary <TKey, TType> > target, TType value) { return(target.And(new DefaultValidationPredicate <IDictionary <TKey, TType> >(v => v.Values.Contains(value), ExceptionMessages.CollectionsContainsValueFailed .Inject(value)))); }
public static IValidationTarget <IDictionary <TKey, TType> > DoesNotContainKey <TKey, TType>( this IValidationTarget <IDictionary <TKey, TType> > target, TKey key) { return(target.And(new DefaultValidationPredicate <IDictionary <TKey, TType> >(v => { return v.Keys.All(k => !k.Equals(key)); }, ExceptionMessages.DictionariesDoesNotContainKeyFailed .Inject(key)))); }
public static IValidationTarget <TType> HasMaximumCount <TType>(this IValidationTarget <TType> target, int maxCount) where TType : ICollection { return(target.And(new OutOfRangeValidationPredicate <TType>(v => v.Count <= maxCount, ExceptionMessages.CollectionsMaximumSizeIsFailed.Inject( maxCount, target.Value.Count)))); }
public static IValidationTarget <sbyte> IsInRange(this IValidationTarget <sbyte> target, sbyte minValue, sbyte maxValue) { return(target.And(new OutOfRangeValidationPredicate <sbyte>(v => v > minValue, ExceptionMessages.NumbersIsInRangeTooLowFailed.Inject( target.Value, minValue))) .And(new OutOfRangeValidationPredicate <sbyte>(v => v < maxValue, ExceptionMessages.NumbersIsInRangeTooHighFailed .Inject(target.Value, maxValue)))); }