流利的验证。错误:在不显眼的客户端验证规则验证类型名称必须是唯一的 [英] Fluent Validations. Error: Validation type names in unobtrusive client validation rules must be unique
问题描述
我得到了erorr:
验证类型名称
客户端验证规则必须
独特。下面的验证类型
被视为不止一次:必需的。该
下面的验证类型被视为
不止一次:需要
Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: required. The following validation type was seen more than once: required
我使用的服务器验证。和所有工作的罚款。
但现在我真的说明使用客户端验证,我得到了这个问题。
I used server validation. And all worked fine. But now I`m stating to use client-side validation and I got this problem.
这是我的验证类code:
This is my validation class code:
public class TestViewDataValidation : BaseTestCreateViewDataValidation<BaseTestCreateViewData>
{
public TestViewDataValidation ()
{
this.RuleFor(x => x.Login).NotNull();
this.RuleFor(x => x.Login).NotEmpty();
this.RuleFor(x => x.Login).EmailAddress();
}
}
但是,如果我留一个验证 - 一切工作正常。
我应该怎么做才能有更多的领域,一个验证。
But if I leave one validator - all works fine. What should I do to have more that one validation for field.
推荐答案
FluentValidation.NET
被称为流利的,因为它提供了一个的为链接的方法流畅的界面:
FluentValidation.NET
is called Fluent because it provides a fluent interface for chaining methods:
public TestViewDataValidation()
{
RuleFor(x => x.Login)
.NotNull()
.NotEmpty()
.EmailAddress();
}
注: NOTNULL
和 NotEmpty
规则的使用似乎reduntant我在这种情况下。 NotEmpty
应该够了。
Remark: the usage of NotNull
and NotEmpty
rules seem reduntant to me in this case. NotEmpty
should be enough.
这篇关于流利的验证。错误:在不显眼的客户端验证规则验证类型名称必须是唯一的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!