Custom Validator with client side validation

Apr 5, 2012 at 5:04 AM


Are there any end to end examples of creating a custom validators along with custom client side validation as well. I am having alot of trouble getting any client side validation to work with my custom validators and if there are any examples out there on how to hook the client side validation up, it would be much appreciated.

Thanks again for the awesome library!

Apr 5, 2012 at 10:24 AM


I'm afraid I don't have any end-to-end examples for hooking up client-side validation to custom validators, but all the client-side validation is based around ASP.NET MVC's validation infrastructure, so hooking up custom clientside validation with FV is identical to hooking up custom client side validators using DataAnnotations. If you're not familiar with how to do this, I would suggest looking at articles that explain how to use MVC's IClientValidtable interface. Essentially what you need to do is this:

  • Make your custom property validator class implement IClientValidatable
  • The GetClientValidationRules method needs to return a collection of MVC's ModelClientValidationRule which MVC will use to populate custom attributes on your UI elements
  • Write the appropriate client-side logic to interrogate these attributes for performing the validation


Apr 5, 2012 at 2:07 PM

Thanks Jeremy,

I think it was a case of being to tired to see the error in my ways. I am using ninject for DI, and I wasn't adding my custom adapter to to the FluentValidationModelValiadtorProvider properly, hence why the client side rule where never getting added.

This is why you shouldn't code when your on 2 hours of sleep :)

And just in case someone else needs help, you can take a look at this stackoverflow question which has a nice walkthrough of whats needed. I wish I found this before falling through this :)

Thanks again!

May 25, 2012 at 4:12 PM
Edited May 25, 2012 at 4:16 PM


Post deleted.

Sep 30, 2013 at 2:30 PM
Edited Sep 30, 2013 at 2:31 PM
i also facing the same problem. I add all scripts like(1.7.1, unobtrusive,and validate) but still post back is going on.. so please help me out.. with example...
Sep 30, 2013 at 4:00 PM
Sure would be cool if client validation on as many of these fluent validation rules were implemented and shipped out of the box. Hint, hint... :-)