示例#1
0
 public static IMemberSpecificationBuilder <TModel, sbyte?> LessOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, sbyte?> @this, sbyte max)
     where TModel : class
 {
     return(@this.AsNullable(m => m.LessOrEqualTo(max)));
 }
示例#2
0
 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) }));
 }
示例#3
0
 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) }));
 }
示例#4
0
 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) }));
 }
示例#5
0
        /// <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);
        }
示例#6
0
 /// <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));
 }
示例#7
0
 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) }));
 }
示例#8
0
 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));
 }
示例#9
0
 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>());
 }
示例#10
0
 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)));
 }
示例#11
0
 public static IMemberSpecificationBuilder <TModel, ushort?> EqualTo <TModel>(this IMemberSpecificationBuilder <TModel, ushort?> @this, ushort value)
     where TModel : class
 {
     return(@this.AsNullable(m => m.EqualTo(value)));
 }
示例#12
0
 public static IMemberSpecificationBuilder <TModel, ushort?> LessThan <TModel>(this IMemberSpecificationBuilder <TModel, ushort?> @this, ushort max)
     where TModel : class
 {
     return(@this.AsNullable(m => m.LessThan(max)));
 }
示例#13
0
 public static IMemberSpecificationBuilder <TModel, ushort?> GreaterOrEqualTo <TModel>(this IMemberSpecificationBuilder <TModel, ushort?> @this, ushort min)
     where TModel : class
 {
     return(@this.AsNullable(m => m.GreaterOrEqualTo(min)));
 }
示例#14
0
 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)));
 }
示例#15
0
 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>());
 }
示例#16
0
 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));
 }
示例#17
0
        /// <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);
        }
示例#18
0
 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));
 }
示例#19
0
 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) }));
 }
示例#20
0
 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));
 }
示例#21
0
 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) }));
 }
示例#22
0
 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));
 }
示例#23
0
 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) }));
 }
示例#24
0
 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));
 }
示例#25
0
 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) }));
 }
示例#26
0
 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));
 }
示例#27
0
 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) }));
 }
示例#28
0
 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));
 }
示例#29
0
 /// <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));
 }
示例#30
0
 public static IMemberSpecificationBuilder <TModel, sbyte?> GreaterThan <TModel>(this IMemberSpecificationBuilder <TModel, sbyte?> @this, sbyte min)
     where TModel : class
 {
     return(@this.AsNullable(m => m.GreaterThan(min)));
 }