using System.ComponentModel.DataAnnotations;
using Kurisu.AspNetCore.Utils.Extensions;
namespace Dlhis.Basic.Organization.Request;
public class MigrationRequest : IValidatableObject
{
///
/// 工号
///
[Required(ErrorMessage = "工号不能为空")]
public string Code { get; set; }
///
/// 卡号
///
public string CardNo { get; set; }
///
/// base64
///
public string Face { get; set; }
public IEnumerable Validate(ValidationContext validationContext)
{
if (Face.IsPresent())
{
bool v = true;
try
{
Convert.FromBase64String(Face);
}
catch (Exception)
{
v = false;
}
if (!v)
{
yield return new ValidationResult("人脸照片需要为Base64格式", new[] { nameof(Face) });
}
}
}
}