Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure NancyFx with Fluent Validation

Is there any configuration code that I have to add in the application Bootstrapper to enable FluentValidation in Nancy?

Following the example from https://github.com/NancyFx/Nancy/tree/master/src/Nancy.Demo.Validation I receive the following exception message when trying to use this.Validate on model: No model validator factory could be located.

I'm using Nancy version 0.11.0.0

like image 326
Emilian Avatar asked Aug 29 '12 12:08

Emilian


People also ask

What is fluent validation?

FluentValidation is a .NET library for building strongly-typed validation rules. It Uses a fluent interface and lambda expressions for building validation rules. It helps clean up your domain code and make it more cohesive, as well as giving you a single place to look for validation logic.

Is fluent validation good?

FluentValidation provides a great alternative to Data Annotations in order to validate models. It gives better control of validation rules and makes validation rules easy to read, easy to test, and enable great separation of concerns.

Is Fluent validation free?

FluentValidation is developed for free by @JeremySkinner in his spare time and financial sponsorship helps keep the project going. Please sponsor the project via either GitHub sponsors or OpenCollective.


1 Answers

Are you using one of the Bootstrapper packages (autofac, ninject, unity, windsor, structuremap)? If you are then you need to inherit from the bootstrapper type, override ConfigureApplicationContainer and register the type in the container. If you are using the default bootstrapper then it should wire itself up

With out next release, 0.12, it will wired up automatically no matter what bootstrapper you are using

like image 186
TheCodeJunkie Avatar answered Oct 21 '22 04:10

TheCodeJunkie