public static IRuleOut <IReadOnlyList <TItem> > ExactCollectionSize <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this, int size) { return(@this.ExactCollectionSize <IReadOnlyList <TItem>, TItem>(size)); }
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))); }
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))); }
/// <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))); }
public static IRuleOut <uint> Positive(this IRuleIn <uint> @this) { return(@this.RuleTemplate(m => m > 0, MessageKey.Numbers.Positive)); }
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))); }
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))); }
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))); }
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))); }
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))); }
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))); }
public static IRuleOut <IReadOnlyList <TItem> > EmptyCollection <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this) { return(@this.EmptyCollection <IReadOnlyList <TItem>, TItem>()); }
public static IRuleOut <IReadOnlyList <TItem> > CollectionSizeBetween <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this, int min, int max) { return(@this.CollectionSizeBetween <IReadOnlyList <TItem>, TItem>(min, max)); }
public static IRuleOut <IReadOnlyList <TItem> > MinCollectionSize <TItem>(this IRuleIn <IReadOnlyList <TItem> > @this, int min) { return(@this.MinCollectionSize <IReadOnlyList <TItem>, TItem>(min)); }
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))); }
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))); }
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))); }
public static IRuleOut <sbyte> Negative(this IRuleIn <sbyte> @this) { return(@this.RuleTemplate(m => m < 0, MessageKey.Numbers.Negative)); }
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))); }
public static IRuleOut <sbyte?> NonNegative(this IRuleIn <sbyte?> @this) { return(@this.RuleTemplate(m => m.Value >= 0, MessageKey.Numbers.NonNegative)); }
public static IRuleOut <byte> NonZero(this IRuleIn <byte> @this) { return(@this.RuleTemplate(m => m != 0, MessageKey.Numbers.NonZero)); }
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))); }
public static IRuleOut <uint?> NonZero(this IRuleIn <uint?> @this) { return(@this.RuleTemplate(m => m.Value != 0, MessageKey.Numbers.NonZero)); }
public static IRuleOut <byte?> Positive(this IRuleIn <byte?> @this) { return(@this.RuleTemplate(m => m.Value > 0, MessageKey.Numbers.Positive)); }
public static IRuleOut <uint?> NonPositive(this IRuleIn <uint?> @this) { return(@this.RuleTemplate(m => m.Value <= 0, MessageKey.Numbers.NonPositive)); }
public static IRuleOut <byte> NonPositive(this IRuleIn <byte> @this) { return(@this.RuleTemplate(m => m <= 0, MessageKey.Numbers.NonPositive)); }
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))); }
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))); }
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))); }
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))); }