src/EasyFrameWork/ViewPort/Validator/StringLengthValidator.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using Easy.Extend;
namespace Easy.ViewPort.Validator
{
public class StringLengthValidator : ValidatorBase
{
public StringLengthValidator(int min, int max)
{
this.Max = max;
this.Min = min;
if (Max > 0 && Min > 0)
{
this.BaseErrorMessage = "{0} length should be between {1} to {2}";
}
else if (Max > 0)
{
this.BaseErrorMessage = "{0} length should be less than {1}";
}
else if (Min > 0)
{
this.BaseErrorMessage = "{0} length should be greater than {1}";
}
}
public int Max { get; set; }
public int Min { get; set; }
public override bool Validate(object value)
{
if (value == null) return true;
string val = value.ToString();
if (Max > 0 && Min > 0)
{
return val.Length >= Min && val.Length <= Max;
}
else if (Max > 0)
{
return val.Length <= Max;
}
else if (Min > 0)
{
return val.Length >= Min;
}
else
{
return false;
}
}
public override string FormatMessage(string key)
{
if (Max > 0 && Min > 0)
{
return string.Format(key, GetDisplayName(), Min, Max);
}
后面还有 12 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。