This commit is contained in:
Yuan
2022-07-24 14:48:54 +08:00
parent 5907f586ce
commit baf1bae943
115 changed files with 19923 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Appointment.Entity.ValidateAttribute
{
/// <summary>
/// 字符串最大长度
/// </summary>
/// <remarks>
/// Add:yuangb 2020-12-9
/// 使用格式:实体属性前加 [StringMaxLength(200, ErrorMessage = "备注说明最大长度200个字符")]
/// </remarks>
public class StringMaxLengthAttribute : ValidateAttribute
{
private int _MaxLength = 0;
/// <summary>
/// 报错提示
/// </summary>
public string ErrorMessage { get; set; }
public StringMaxLengthAttribute(int maxLength)
{
_MaxLength = maxLength;
}
public override string Validate(object oValue)
{
if (oValue != null && oValue.ToString().Length > _MaxLength)
{
return ErrorMessage;
}
return null;
}
}
}