views:

174

answers:

1

Can you validate just a single property with the Fluent Validation Library, and if so how? I thought this discussion thread from January of 2009 showed me how to do it via the following syntax:

validator.Validate(new Person(), x => x.Surname);

Unfortunately it doesn't appear this works in the current version of the library. One other thing that led me to believe that validating a single property might be possible is the following quote from 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. "

However I do not know if that necessarily means it supports just validating a single property or the fact that you can tell the validation library to stop validating after the first validation error.

+1  A: 

According to this discussion on CodePlex, that ability is added by way of extension methods. You would need to import the FluentValidation namespace to have those show up in IntelliSense.

patridge