标签:bubuko htm not tran image 图片 uml com max
官方文档:https://fluentvalidation.net/
1、建立PostValidator:
public class PostValidator:AbstractValidator<PostDTO> { public PostValidator() { RuleFor(x => x.Author).NotEmpty() .WithName("作者").WithMessage("{PropertyName}是必须填写的") .MaximumLength(50).WithMessage("{PropertyName}的最大长度是{MaxLength}"); } }
2、aspnetcore注册:
services.AddTransient<IValidator<PostDTO>, PostValidator>();
参考资料:https://v.qq.com/x/page/z0763a2x3j5.html
ASP NET Core ---FluentValidation
标签:bubuko htm not tran image 图片 uml com max
原文地址:https://www.cnblogs.com/fuyouchen/p/9588987.html