예제 #1
0
 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))));
 }
예제 #2
0
 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))));
 }
예제 #4
0
 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))));
 }
예제 #6
0
 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))));
 }
예제 #7
0
 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))));
 }
예제 #8
0
 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))));
 }
예제 #9
0
 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))));
 }
예제 #10
0
 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))));
 }
예제 #11
0
 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))));
 }
예제 #12
0
 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))));
 }
예제 #16
0
 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)));
 }
예제 #17
0
 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)));
 }
예제 #18
0
 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))));
 }
예제 #19
0
 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))));
 }
예제 #20
0
 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))));
 }
예제 #21
0
 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))));
 }
예제 #22
0
 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))));
 }
예제 #23
0
 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))));
 }
예제 #24
0
 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))));
 }
예제 #25
0
 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)));
 }
예제 #26
0
 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))));
 }
예제 #27
0
 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))));
 }
예제 #28
0
 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))));
 }
예제 #29
0
 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))));
 }
예제 #30
0
 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))));
 }