【问题标题】:Configure NancyFx with Fluent Validation使用 Fluent Validation 配置 NancyFx
【发布时间】:2012-08-24 01:53:53
【问题描述】:

我是否必须在应用程序 Bootstrapper 中添加任何配置代码才能在 Nancy 中启用 FluentValidation?

按照https://github.com/NancyFx/Nancy/tree/master/src/Nancy.Demo.Validation 的示例,我在尝试使用 this.Validate on model 时收到以下异常消息:无法找到模型验证器工厂

我使用的是 Nancy 版本 0.11.0.0

【问题讨论】:

    标签: configuration fluentvalidation nancy


    【解决方案1】:

    您是否正在使用 Bootstrapper 软件包之一(autofac、ninject、unity、windsor、structuremap)?如果是,那么您需要从引导程序类型继承,覆盖 ConfigureApplicationContainer 并在容器中注册类型。如果您使用的是默认引导程序,那么它应该自行连接

    没有下一个版本,0.12,无论您使用什么引导程序,它都会自动连接

    【讨论】:

    • 是的,我的应用程序 Bootstrapper 继承了 NinjectNancyBootstrapper。我已经为 IFluentAdapterFactory 和 FluentValidationValidatorFactory 为 IModelValidatorFactory 注册了 DefaultFluentAdapterFactory 并且它有效。这两个中的任何一个都应该注册为单身人士吗?
    • 是的,单身很好。南希被设计成无国籍的
    猜你喜欢
    • 2015-11-05
    • 2015-01-20
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 2018-04-02
    • 2011-12-26
    • 2023-04-11
    • 1970-01-01
    相关资源
    最近更新 更多