Browse Source

Improved

pull/5261/head
liangshiwei 6 years ago
parent
commit
a2743fd3cd
  1. 10
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicRangeAttributeAdapter.cs
  2. 2
      framework/src/Volo.Abp.Core/Volo/Abp/Validation/DynamicRangeAttribute.cs

10
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicRangeAttributeAdapter.cs

@ -17,8 +17,8 @@ namespace Volo.Abp.AspNetCore.Mvc.DataAnnotations
IStringLocalizer stringLocalizer)
: base(attribute, stringLocalizer)
{
_min = Attribute.Minimum.ToString()?.ToString(CultureInfo.InvariantCulture);
_max = Attribute.Maximum.ToString()?.ToString(CultureInfo.InvariantCulture);
_min = Convert.ToString(Attribute.Minimum,CultureInfo.InvariantCulture);
_max = Convert.ToString(Attribute.Maximum,CultureInfo.InvariantCulture);
}
public override void AddValidation(ClientModelValidationContext context)
@ -26,9 +26,9 @@ namespace Volo.Abp.AspNetCore.Mvc.DataAnnotations
Check.NotNull(context, nameof(context));
MergeAttribute(context.Attributes, "data-val", "true");
MergeAttribute(context.Attributes, "data-val-length", GetErrorMessage(context));
MergeAttribute(context.Attributes, "data-val-length-min", _min);
MergeAttribute(context.Attributes, "data-val-length-max", _max);
MergeAttribute(context.Attributes, "data-val-range", GetErrorMessage(context));
MergeAttribute(context.Attributes, "data-val-range-min", _min);
MergeAttribute(context.Attributes, "data-val-range-max", _max);
}
public override string GetErrorMessage(ModelValidationContextBase validationContext)

2
framework/src/Volo.Abp.Core/Volo/Abp/Validation/DynamicRangeAttribute.cs

@ -27,9 +27,9 @@ namespace Volo.Abp.Validation
}
/// <param name="sourceType">A type to get the values of the properties</param>
/// <param name="operandType">The type of the range parameters. Must implement IComparable. <see cref="RangeAttribute.OperandType"/></param>
/// <param name="minimumPropertyName">The name of the public static property for the <see cref="RangeAttribute.Minimum"/></param>
/// <param name="maximumPropertyName">The name of the public static property for the <see cref="RangeAttribute.Maximum"/></param>
/// <param name="operandType">The type of the range parameters. Must implement IComparable. <see cref="RangeAttribute.OperandType"/></param>
public DynamicRangeAttribute(
[NotNull] Type sourceType,
[NotNull] Type operandType,

Loading…
Cancel
Save