0
我有一個fluentvalidation(版本3.4.6.0與fluentvalidation.MVC4,jQuery驗證1.9.0.1)的問題,驗證將失敗,當值爲0,它不應該。這是我的代碼和一個失敗的測試。FluentValidation和GreaterThanOrEqualTo規則的值爲0
public class SomeModel
{
public string Id { get; set; }
public decimal Price { get; set; }
}
public class EditMachineValidator : AbstractValidator<SomeModel>
{
public SomeModelValidator()
{
RuleFor(x => x.Price).NotEmpty();
RuleFor(x => x.Price).GreaterThanOrEqualTo(0m);
}
}
[Fact]
public void Should_Not_Have_Error_When_Price_Is_Zero()
{
var validator = SomeModelValidator();
validator.ShouldNotHaveValidationErrorFor(x => x.Price, 0m);
}
我在這裏做錯了什麼?
看起來你是對的,感謝您的幫助! – Pelle