예제 #1
0
 public static IRuleOut <IReadOnlyList <TItem> > ExactCollectionSize <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this, int size)
 {
     return(@this.ExactCollectionSize <IReadOnlyList <TItem>, TItem>(size));
 }
예제 #2
0
 public static IRuleOut <uint?> NotEqualTo(this IRuleIn <uint?> @this, uint value)
 {
     return(@this.RuleTemplate(m => m.Value != value, MessageKey.Numbers.NotEqualTo, Arg.Number(nameof(value), value)));
 }
예제 #3
0
 public static IRuleOut <uint?> GreaterThanOrEqualTo(this IRuleIn <uint?> @this, uint min)
 {
     return(@this.RuleTemplate(m => m.Value >= min, MessageKey.Numbers.GreaterThanOrEqualTo, Arg.Number(nameof(min), min)));
 }
예제 #4
0
        /// <summary>
        /// Validates the current scope value against the specification. The error output is saved in the current scope.
        /// This is a scope command - its error output can be altered with any of the parameter commands (WithCondition, WithPath, WithMessage, WithExtraMessage, WithCode, WithExtraCode).
        /// </summary>
        /// <param name="this">Fluent API builder - input.</param>
        /// <param name="specification">Specification for the current scope value.</param>
        /// <typeparam name="T">Type of the current scope value.</typeparam>
        /// <returns>Fluent API builder - output.</returns>
        public static IRuleOut <T> AsModel <T>(this IRuleIn <T> @this, Specification <T> specification)
        {
            ThrowHelper.NullArgument(@this, nameof(@this));

            return(((SpecificationApi <T>)@this).AddCommand(new AsModelCommand <T>(specification)));
        }
예제 #5
0
 public static IRuleOut <uint> Positive(this IRuleIn <uint> @this)
 {
     return(@this.RuleTemplate(m => m > 0, MessageKey.Numbers.Positive));
 }
예제 #6
0
        public static IRuleOut <byte> Between(this IRuleIn <byte> @this, byte min, byte max)
        {
            ThrowHelper.InvalidRange(min, nameof(min), max, nameof(max));

            return(@this.RuleTemplate(m => m > min && m < max, MessageKey.Numbers.Between, Arg.Number(nameof(min), min), Arg.Number(nameof(max), max)));
        }
예제 #7
0
        public static IRuleOut <byte?> BetweenOrEqualTo(this IRuleIn <byte?> @this, byte min, byte max)
        {
            ThrowHelper.InvalidRange(min, nameof(min), max, nameof(max));

            return(@this.RuleTemplate(m => m.Value >= min && m.Value <= max, MessageKey.Numbers.BetweenOrEqualTo, Arg.Number(nameof(min), min), Arg.Number(nameof(max), max)));
        }
예제 #8
0
 public static IRuleOut <DateTime> Between(this IRuleIn <DateTime> @this, DateTime min, DateTime max, TimeComparison timeComparison = TimeComparison.All)
 {
     return(@this.RuleTemplate(m => TimeComparer.Compare(m, min, timeComparison) > 0 && TimeComparer.Compare(m, max, timeComparison) < 0, MessageKey.Times.Between, Arg.Time(nameof(min), min), Arg.Time(nameof(max), max), Arg.Enum(nameof(timeComparison), timeComparison)));
 }
예제 #9
0
 public static IRuleOut <DateTime?> BetweenOrEqualTo(this IRuleIn <DateTime?> @this, DateTime min, DateTime max, TimeComparison timeComparison = TimeComparison.All)
 {
     return(@this.RuleTemplate(m => TimeComparer.Compare(m.Value, min, timeComparison) >= 0 && TimeComparer.Compare(m.Value, max, timeComparison) <= 0, MessageKey.Times.BetweenOrEqualTo, Arg.Time(nameof(min), min), Arg.Time(nameof(max), max), Arg.Enum(nameof(timeComparison), timeComparison)));
 }
예제 #10
0
 public static IRuleOut <DateTime> AfterOrEqualTo(this IRuleIn <DateTime> @this, DateTime min, TimeComparison timeComparison = TimeComparison.All)
 {
     return(@this.RuleTemplate(m => TimeComparer.Compare(m, min, timeComparison) >= 0, MessageKey.Times.AfterOrEqualTo, Arg.Time(nameof(min), min), Arg.Enum(nameof(timeComparison), timeComparison)));
 }
예제 #11
0
 public static IRuleOut <DateTime> BeforeOrEqualTo(this IRuleIn <DateTime> @this, DateTime max, TimeComparison timeComparison = TimeComparison.All)
 {
     return(@this.RuleTemplate(m => TimeComparer.Compare(m, max, timeComparison) <= 0, MessageKey.Times.BeforeOrEqualTo, Arg.Time(nameof(max), max), Arg.Enum(nameof(timeComparison), timeComparison)));
 }
예제 #12
0
 public static IRuleOut <IReadOnlyList <TItem> > EmptyCollection <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this)
 {
     return(@this.EmptyCollection <IReadOnlyList <TItem>, TItem>());
 }
예제 #13
0
 public static IRuleOut <IReadOnlyList <TItem> > CollectionSizeBetween <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this, int min, int max)
 {
     return(@this.CollectionSizeBetween <IReadOnlyList <TItem>, TItem>(min, max));
 }
예제 #14
0
 public static IRuleOut <IReadOnlyList <TItem> > MinCollectionSize <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this, int min)
 {
     return(@this.MinCollectionSize <IReadOnlyList <TItem>, TItem>(min));
 }
예제 #15
0
 public static IRuleOut <byte> GreaterThanOrEqualTo(this IRuleIn <byte> @this, byte min)
 {
     return(@this.RuleTemplate(m => m >= min, MessageKey.Numbers.GreaterThanOrEqualTo, Arg.Number(nameof(min), min)));
 }
예제 #16
0
 public static IRuleOut <DateTime> EqualTo(this IRuleIn <DateTime> @this, DateTime value, TimeComparison timeComparison = TimeComparison.All)
 {
     return(@this.RuleTemplate(m => TimeComparer.Compare(m, value, timeComparison) == 0, MessageKey.Times.EqualTo, Arg.Time(nameof(value), value), Arg.Enum(nameof(timeComparison), timeComparison)));
 }
예제 #17
0
 public static IRuleOut <byte?> LessThanOrEqualTo(this IRuleIn <byte?> @this, byte max)
 {
     return(@this.RuleTemplate(m => m.Value <= max, MessageKey.Numbers.LessThanOrEqualTo, Arg.Number(nameof(max), max)));
 }
예제 #18
0
 public static IRuleOut <sbyte> Negative(this IRuleIn <sbyte> @this)
 {
     return(@this.RuleTemplate(m => m < 0, MessageKey.Numbers.Negative));
 }
예제 #19
0
 public static IRuleOut <byte> EqualTo(this IRuleIn <byte> @this, byte value)
 {
     return(@this.RuleTemplate(m => m == value, MessageKey.Numbers.EqualTo, Arg.Number(nameof(value), value)));
 }
예제 #20
0
 public static IRuleOut <sbyte?> NonNegative(this IRuleIn <sbyte?> @this)
 {
     return(@this.RuleTemplate(m => m.Value >= 0, MessageKey.Numbers.NonNegative));
 }
예제 #21
0
 public static IRuleOut <byte> NonZero(this IRuleIn <byte> @this)
 {
     return(@this.RuleTemplate(m => m != 0, MessageKey.Numbers.NonZero));
 }
예제 #22
0
 public static IRuleOut <sbyte?> LessThan(this IRuleIn <sbyte?> @this, sbyte max)
 {
     return(@this.RuleTemplate(m => m.Value < max, MessageKey.Numbers.LessThan, Arg.Number(nameof(max), max)));
 }
예제 #23
0
 public static IRuleOut <uint?> NonZero(this IRuleIn <uint?> @this)
 {
     return(@this.RuleTemplate(m => m.Value != 0, MessageKey.Numbers.NonZero));
 }
예제 #24
0
 public static IRuleOut <byte?> Positive(this IRuleIn <byte?> @this)
 {
     return(@this.RuleTemplate(m => m.Value > 0, MessageKey.Numbers.Positive));
 }
예제 #25
0
 public static IRuleOut <uint?> NonPositive(this IRuleIn <uint?> @this)
 {
     return(@this.RuleTemplate(m => m.Value <= 0, MessageKey.Numbers.NonPositive));
 }
예제 #26
0
 public static IRuleOut <byte> NonPositive(this IRuleIn <byte> @this)
 {
     return(@this.RuleTemplate(m => m <= 0, MessageKey.Numbers.NonPositive));
 }
예제 #27
0
 public static IRuleOut <uint> GreaterThan(this IRuleIn <uint> @this, uint min)
 {
     return(@this.RuleTemplate(m => m > min, MessageKey.Numbers.GreaterThan, Arg.Number(nameof(min), min)));
 }
예제 #28
0
 public static IRuleOut <byte?> GreaterThan(this IRuleIn <byte?> @this, byte min)
 {
     return(@this.RuleTemplate(m => m.Value > min, MessageKey.Numbers.GreaterThan, Arg.Number(nameof(min), min)));
 }
예제 #29
0
 public static IRuleOut <uint> LessThan(this IRuleIn <uint> @this, uint max)
 {
     return(@this.RuleTemplate(m => m < max, MessageKey.Numbers.LessThan, Arg.Number(nameof(max), max)));
 }
예제 #30
0
        public static IRuleOut <decimal> BetweenOrEqualTo(this IRuleIn <decimal> @this, decimal min, decimal max)
        {
            ThrowHelper.InvalidRange(min, nameof(min), max, nameof(max));

            return(@this.RuleTemplate(m => m >= min && m <= max, MessageKey.Numbers.BetweenOrEqualTo, Arg.Number(nameof(min), min), Arg.Number(nameof(max), max)));
        }