你能用
Fluent Validation库验证一个属性,如果是,如何?我以为
this discussion thread from January of 2009通过以下语法向我展示了如何做到这一点:
validator.Validate(new Person(),x => x.Surname);
不幸的是,它似乎不适用于当前版本的库.另一件让我相信可能有可能验证单个属性的事情是来自Jeremy Skinners’ blog post的以下引用:
“Finally,I added the ability to be able to execute some of FluentValidation’s Property Validators without needing to validate the entire object. This means it is Now possible to stop the default “A value was required” message from being added to ModelState. “