Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting up ninject.web.mvc.fluentvalidation is not straight forward #6

Open
menaheme opened this issue Dec 17, 2013 · 2 comments
Open

Comments

@menaheme
Copy link

Hi ,
First of all, i am very grateful for all the work put in the Ninject project and its extensions.

to the issues: using MVC4 on VC2012 Pro, wanting Ninject + FluentValidation

  1. installed the ninject MVC3 and fluent validation mvc4 + the ninject fluent validation extension, all using nuget. since using only stable versions, i ran into the signing issue
    as seen here , i would like very much for the package from nuget to work without the workaround.
  2. i used a single simple model object with nothing on it but auto props.
    added a simple validator class using AbstactValidator, with a single simple RuleFor rule.
    running with F5 , didnt activate the validator. (i saw the instructions but they are not clear as to where to put the first snippet marked "1" , and the NinjectModule (also marked "1") is never loaded, by anyone.)
    google around for quite a bit got me here, and now the validator gets loaded.
    i think the nuget should also put the code linked above, in the proper places, especially the NinjectModule and add it to the the kernel`s initialization. the problem is that installing the extension leaves you half way through, and its not so easy to complete the task.
  3. now that the validator is loaded, i get the dreaded "Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: required", as answered by Remo Gloor here.
    it still does not work for me (Remo`s answer does not work for me, the AttributeValidatorProvider class is not in any referenced assembly). Again i think it should work right after installing the Nuget and hitting F5.

there`r a lot of question at StackOverflow on all 3 points, so im not the only one having a hard time.

i would very much appreciate your response.

@rexcfnghk
Copy link
Contributor

Is anyone following up with this? Is it ok if I have a go and try to update the documentaion? I am thinking of introduce a new dependency (through NuGet) on Ninject.Web.Common so that NinjectValidatorFactory can be set up in Global.asax.cs like this:

protected void Application_Start()
{
    var kernel = DependendencyResolver.Current.GetService<IKernel>();
    var ninjectValidatorFacotry = new NinjectValidatorFactory(kernel);
    ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(ninjectValidatorFactory));
    DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
}

Is this solution acceptable?

@ciaran036
Copy link

Anyone got a complete guide to configuring Ninject with FluentValidation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants