using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OASystem.Domain.Dtos.Tencent
{
///
/// OCR 继承基类
///
public class OCRDtoBase
{
///
/// 图片转base64 字符串
///
public string picBase64 { get; set; }
///
/// 语种
/// 1 中文
/// 2 英文
///
public int language { get; set; }
}
///
/// 验证
///
public class OCRDtoBaseFoalidator : AbstractValidator
{
public OCRDtoBaseFoalidator()
{
RuleFor(it => it.picBase64)
.NotEmpty()
.NotNull()
.WithMessage("picBase64为空");
RuleFor(it => it.picBase64)
.Must(base64 => OCRVerifyMethod.ImageSize(base64))
.WithMessage("图片不能大于7M!");
//RuleFor(it => it.picBase64)
// .Must(base64 => OCRVerifyMethod.ImageType(base64))
// .WithMessage("图片格式不正确!只支持 PNG、JPG、JPEG、BMP格式的文件!");
RuleFor(it => it.language)
.InclusiveBetween(1, 2)
.WithMessage("language(超出范围):1 中文 2 英文");
}
}
}