Fluent validation or EntLib Validation Application Block for WCF services

1.9k views Asked by At

I am looking for a standard way to add validation of the input parameters to the set of WCF services.

Can anyone give comparison of Fluent validation http://fluentvalidation.codeplex.com/ and EntLib Validation Application Block?

What are advantages/disadvantages of each of them?

What are scenarios when one or another should be used?

My question is similar to Which validation framework would you recommend for .net projects? and Which validation framework to choose: Spring Validation or Validation Application Block (Enterprise LIbrary 4.0)? , but the answers to these questions do not have detailed comparison.

I would appreciate if some other similar technology would be recommended( with reasoning why)

Does anyone has experience with both framework and select one for their projects? What were the reasons for the decision?

1

There are 1 answers

1
Michael Freidgeim On BEST ANSWER

After a few months I can answer, that EntLib Validation Application block(VAB) is a mature library which  supports code, attribute and configuration validation.

In most cases developers should start with attribute validation of DataMember properties in DataContract request as the simplest and concise way.

If you expect that Validation rules will be changed frequently or different installations of application will need different rules for the same property(e.g. Zip code rules are different for different countries), you should choose configuration. It is not straightforward and required a learning, but flexibility is an advantage. EntLib config editor can be helpful to make it easier.

Only for complex rules, that can't be expressed using attributes or configuration, you should write code. If you are repeating the same rules a few times, consider to create custom validator and validation attribute.

Fluent validation library supports adding validation in code, that is less desirable method. So I don't understand, why Fluent validation is so popular. Also I was surprised, that  Fluent validation author is not familiar with EntLib VAB.

My original question was about input parameters for WCF operations. However the best practices recommend to use single request parameter as data contract rather then multiple RPC style simple parameters. Anyway  VAB provide attributes for individual parameters of WCF operations, which gives more concise view (e.g. See http://www.codeproject.com/Articles/259327/Integrate-Validation-Block-with-WCF