/// <summary> /// Bind the incoming request to an existing instance and validate /// </summary> /// <typeparam name="TModel">Model type</typeparam> /// <param name="module">Current module</param> /// <param name="instance">The class instance to bind properties to</param> /// <param name="configuration">The <see cref="BindingConfig"/> that should be applied during binding.</param> /// <param name="blacklistedProperties">Property names to blacklist from binding</param> /// <remarks><see cref="ModelValidationResult"/> is stored in NancyModule.ModelValidationResult and NancyContext.ModelValidationResult.</remarks> public static TModel BindToAndValidate <TModel>(this NancyModule module, TModel instance, BindingConfig configuration, params string[] blacklistedProperties) { var model = module.BindTo <TModel>(instance, configuration, blacklistedProperties); module.Validate(model); return(model); }
/// <summary> /// Bind the incoming request to an existing instance /// </summary> /// <typeparam name="TModel">Model type</typeparam> /// <param name="module">Current module</param> /// <param name="instance">The class instance to bind properties to</param> /// <param name="blacklistedProperties">Property names to blacklist from binding</param> public static TModel BindTo <TModel>(this NancyModule module, TModel instance, params string[] blacklistedProperties) { return(module.BindTo(instance, BindingConfig.Default, blacklistedProperties)); }