123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using FluentValidation;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OASystem.Domain.Dtos.Tencent
- {
- /// <summary>
- /// OCR 继承基类
- /// </summary>
- public class OCRDtoBase
- {
- /// <summary>
- /// 图片转base64 字符串
- /// </summary>
- public string picBase64 { get; set; }
- /// <summary>
- /// 语种
- /// 1 中文
- /// 2 英文
- /// </summary>
- public int language { get; set; }
- }
- /// <summary>
- /// 验证
- /// </summary>
- public class OCRDtoBaseFoalidator : AbstractValidator<OCRDtoBase>
- {
- 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 英文");
- }
- }
- }
|