Files
AppointmentOA/api_v1/Appointment.Entity/ValidateAttribute/StringRequiredAttribute.cs
2022-07-24 14:48:54 +08:00

34 lines
797 B
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace Appointment.Entity.ValidateAttribute
{
/// <summary>
/// 必填项
/// </summary>
/// <remarks>
/// Add:yuangb 2019-3-11
/// [StringRequired(ErrorMessage ="状态不能为空")]
/// </remarks>
public class StringRequiredAttribute : ValidateAttribute
{
/// <summary>
/// 报错提示信息
/// </summary>
public string ErrorMessage { get; set; }
public override string Validate(object oValue)
{
if (oValue == null || string.IsNullOrWhiteSpace(oValue.ToString()))
{
return ErrorMessage;
}
else
{
return null;
}
}
}
}