Hishop.Components.Validation/Validators/StringLengthValidatorAttribute.cs
(完整代码) 1KBnamespace Hishop.Components.Validation.Validators
{
using Hishop.Components.Validation;
using System;
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
public sealed class StringLengthValidatorAttribute : ValueValidatorAttribute
{
private int lowerBound;
private RangeBoundaryType lowerBoundType;
private int upperBound;
private RangeBoundaryType upperBoundType;
public StringLengthValidatorAttribute(int upperBound) : this(0, RangeBoundaryType.Ignore, upperBound, RangeBoundaryType.Inclusive)
{
}
public StringLengthValidatorAttribute(int lowerBound, int upperBound) : this(lowerBound, RangeBoundaryType.Inclusive, upperBound, RangeBoundaryType.Inclusive)
{
}
public StringLengthValidatorAttribute(int lowerBound, RangeBoundaryType lowerBoundType, int upperBound, RangeBoundaryType upperBoundType)
{
this.lowerBound = lowerBound;
this.lowerBoundType = lowerBoundType;
this.upperBound = upperBound;
this.upperBoundType = upperBoundType;
}
protected override Validator DoCreateValidator(Type targetType)
{
return new StringLengthValidator(this.lowerBound, this.lowerBoundType, this.upperBound, this.upperBoundType, base.Negated);
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
