public static IMemberSpecificationBuilder <TModel, sbyte?> LessOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, sbyte?> @this, sbyte max) where TModel : class { return(@this.AsNullable(m => m.LessOrEqualTo(max))); }
public static IMemberSpecificationBuilder <TModel, int> LessOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, int> @this, int max) where TModel : class { return(@this.Valid(m => m <= max, Phrases.Keys.Numbers.LessOrEqualTo, new[] { Arg.Number(nameof(max), max) })); }
public static IMemberSpecificationBuilder <TModel, int> EqualTo <TModel>(this IMemberSpecificationBuilder <TModel, int> @this, int value) where TModel : class { return(@this.Valid(m => m == value, Phrases.Keys.Numbers.EqualTo, new[] { Arg.Number(nameof(value), value) })); }
public static IMemberSpecificationBuilder <TModel, float> LessThan <TModel>(this IMemberSpecificationBuilder <TModel, float> @this, float max) where TModel : class { return(@this.Valid(m => m < max, Phrases.Keys.Numbers.LessThan, new[] { Arg.Number(nameof(max), max) })); }
/// <summary> /// Sets the validation logic for the member as a nested model. /// If the member is null, the validation logic is not triggered and no error is added. /// </summary> /// <typeparam name="TModel">Type of the parent model.</typeparam> /// <typeparam name="TMember">Type of the nested model.</typeparam> /// <param name="this"></param> /// <param name="modelSpecification"> /// The specification for the nested model's type <typeparamref name="TMember" />. If /// null, using specification registered in the related ValidationContext. /// </param> public static IMemberSpecificationBuilder <TModel, TMember> AsModel <TModel, TMember>(this IMemberSpecificationBuilder <TModel, TMember> @this, Specification <TMember> modelSpecification = null) where TModel : class where TMember : class { var memberSpecification = (MemberSpecificationBuilder <TModel, TMember>)@this; memberSpecification.AddCommand(new AsModelRule <TMember>(modelSpecification)); return(@this); }
/// <summary> /// Sets the validation logic for the member as a collection of nested models. /// </summary> /// <typeparam name="TModel">Type of the parent model.</typeparam> /// <typeparam name="TItem">Type of the nested models in the collection.</typeparam> /// <param name="this"></param> /// <param name="specification">The specification for the single nested model in the collection.</param> public static IMemberSpecificationBuilder <TModel, IReadOnlyCollection <TItem> > AsModelsCollection <TModel, TItem>(this IMemberSpecificationBuilder <TModel, IReadOnlyCollection <TItem> > @this, Specification <TItem> specification = null) where TModel : class where TItem : class { return(@this.AsModelsCollection <TModel, IReadOnlyCollection <TItem>, TItem>(specification)); }
public static IMemberSpecificationBuilder <TModel, float> NotCloseTo <TModel>(this IMemberSpecificationBuilder <TModel, float> @this, float value, float tolerance = 0.0000001f) where TModel : class { return(@this.Valid(m => !AreClose(m, value, tolerance), Phrases.Keys.Numbers.NotCloseTo, new[] { Arg.Number(nameof(value), value), Arg.Number(nameof(tolerance), tolerance) })); }
public static IMemberSpecificationBuilder <TModel, TItem[]> ExactCollectionSize <TModel, TItem>(this IMemberSpecificationBuilder <TModel, TItem[]> @this, int size) where TModel : class { return(@this.ExactCollectionSize <TModel, TItem[], TItem>(size)); }
public static IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > NotEmptyCollection <TModel, TItem>(this IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > @this) where TModel : class { return(@this.NotEmptyCollection <TModel, IEnumerable <TItem>, TItem>()); }
public static IMemberSpecificationBuilder <TModel, ushort?> BetweenOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, ushort?> @this, ushort min, ushort max) where TModel : class { return(@this.AsNullable(m => m.BetweenOrEqualTo(min, max))); }
public static IMemberSpecificationBuilder <TModel, ushort?> EqualTo <TModel>(this IMemberSpecificationBuilder <TModel, ushort?> @this, ushort value) where TModel : class { return(@this.AsNullable(m => m.EqualTo(value))); }
public static IMemberSpecificationBuilder <TModel, ushort?> LessThan <TModel>(this IMemberSpecificationBuilder <TModel, ushort?> @this, ushort max) where TModel : class { return(@this.AsNullable(m => m.LessThan(max))); }
public static IMemberSpecificationBuilder <TModel, ushort?> GreaterOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, ushort?> @this, ushort min) where TModel : class { return(@this.AsNullable(m => m.GreaterOrEqualTo(min))); }
public static IMemberSpecificationBuilder <TModel, sbyte?> Between <TModel>(this IMemberSpecificationBuilder <TModel, sbyte?> @this, sbyte min, sbyte max) where TModel : class { return(@this.AsNullable(m => m.Between(min, max))); }
public static IMemberSpecificationBuilder <TModel, List <TItem> > EmptyCollection <TModel, TItem>(this IMemberSpecificationBuilder <TModel, List <TItem> > @this) where TModel : class { return(@this.EmptyCollection <TModel, List <TItem>, TItem>()); }
public static IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > MaxCollectionSize <TModel, TItem>(this IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > @this, long max) where TModel : class { return(@this.MaxCollectionSize <TModel, IEnumerable <TItem>, TItem>(max)); }
/// <summary> /// Sets the validation logic for the member as a collection of nested models. /// </summary> /// <typeparam name="TModel">Type of the parent model.</typeparam> /// <typeparam name="TMember">Type of the collection.</typeparam> /// <typeparam name="TItem">Type of the nested models in the collection.</typeparam> /// <param name="this"></param> /// <param name="specification">The specification for the single nested model in the collection.</param> public static IMemberSpecificationBuilder <TModel, TMember> AsModelsCollection <TModel, TMember, TItem>(this IMemberSpecificationBuilder <TModel, TMember> @this, Specification <TItem> specification = null) where TModel : class where TMember : class, IEnumerable <TItem> where TItem : class { var memberSpecification = (MemberSpecificationBuilder <TModel, TMember>)@this; memberSpecification.AddCommand(new AsCollectionRule <TModel, TItem>(be => be.AsModel(specification))); return(@this); }
public static IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > MinCollectionSize <TModel, TItem>(this IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > @this, int min) where TModel : class { return(@this.MinCollectionSize <TModel, IEnumerable <TItem>, TItem>(min)); }
public static IMemberSpecificationBuilder <TModel, char> EqualIgnoreCase <TModel>(this IMemberSpecificationBuilder <TModel, char> @this, char value) where TModel : class { return(@this.Valid(m => string.Compare(m.ToString().ToUpper(), value.ToString().ToUpper(), CultureInfo.InvariantCulture, CompareOptions.Ordinal) == 0, Phrases.Keys.Char.EqualIgnoreCase, new[] { Arg.Text(nameof(value), value) })); }
public static IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > CollectionSizeBetween <TModel, TItem>(this IMemberSpecificationBuilder <TModel, IEnumerable <TItem> > @this, int min, int max) where TModel : class { return(@this.CollectionSizeBetween <TModel, IEnumerable <TItem>, TItem>(min, max)); }
public static IMemberSpecificationBuilder <TModel, float> GreaterThan <TModel>(this IMemberSpecificationBuilder <TModel, float> @this, float min) where TModel : class { return(@this.Valid(m => m > min, Phrases.Keys.Numbers.GreaterThan, new[] { Arg.Number(nameof(min), min) })); }
public static IMemberSpecificationBuilder <TModel, List <TItem> > ExactCollectionSize <TModel, TItem>(this IMemberSpecificationBuilder <TModel, List <TItem> > @this, long size) where TModel : class { return(@this.ExactCollectionSize <TModel, List <TItem>, TItem>(size)); }
public static IMemberSpecificationBuilder <TModel, float> Between <TModel>(this IMemberSpecificationBuilder <TModel, float> @this, float min, float max) where TModel : class { return(@this.Valid(m => (m > min) && (m < max), Phrases.Keys.Numbers.Between, new[] { Arg.Number(nameof(min), min), Arg.Number(nameof(max), max) })); }
public static IMemberSpecificationBuilder <TModel, List <TItem> > MaxCollectionSize <TModel, TItem>(this IMemberSpecificationBuilder <TModel, List <TItem> > @this, int max) where TModel : class { return(@this.MaxCollectionSize <TModel, List <TItem>, TItem>(max)); }
public static IMemberSpecificationBuilder <TModel, int> GreaterOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, int> @this, int min) where TModel : class { return(@this.Valid(m => m >= min, Phrases.Keys.Numbers.GreaterOrEqualTo, new[] { Arg.Number(nameof(min), min) })); }
public static IMemberSpecificationBuilder <TModel, List <TItem> > MinCollectionSize <TModel, TItem>(this IMemberSpecificationBuilder <TModel, List <TItem> > @this, long min) where TModel : class { return(@this.MinCollectionSize <TModel, List <TItem>, TItem>(min)); }
public static IMemberSpecificationBuilder <TModel, int> BetweenOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, int> @this, int min, int max) where TModel : class { return(@this.Valid(m => (m >= min) && (m <= max), Phrases.Keys.Numbers.BetweenOrEqualTo, new[] { Arg.Number(nameof(min), min), Arg.Number(nameof(max), max) })); }
public static IMemberSpecificationBuilder <TModel, List <TItem> > CollectionSizeBetween <TModel, TItem>(this IMemberSpecificationBuilder <TModel, List <TItem> > @this, long min, long max) where TModel : class { return(@this.CollectionSizeBetween <TModel, List <TItem>, TItem>(min, max)); }
/// <summary> /// Sets the RequiredError for the member (added in case of null). /// </summary> /// <typeparam name="TModel">Type of the parent model.</typeparam> /// <typeparam name="TMember">Type of the member's nullable underlying model.</typeparam> /// <param name="builder"></param> /// <param name="errorMessage">The error message.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="errorMessage" /> is null</exception> public static IMemberSpecificationBuilder <TModel, TMember> SetRequired <TModel, TMember>(this IMemberSpecificationBuilder <TModel, TMember> builder, string errorMessage) where TModel : class where TMember : class { return(((MemberSpecificationBuilder <TModel, TMember>)builder).SetRequired(errorMessage)); }
public static IMemberSpecificationBuilder <TModel, sbyte?> GreaterThan <TModel>(this IMemberSpecificationBuilder <TModel, sbyte?> @this, sbyte min) where TModel : class { return(@this.AsNullable(m => m.GreaterThan(min))); }