Configure NancyFx with Fluent Validation

混江龙づ霸主 提交于 2019-11-29 18:17:38

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/12178201/configure-nancyfx-with-fluent-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!