Search code examples
asp.net-mvcfluentvalidation

Allowing commas in decimal values using Fluent Validation


I am using FluentValidation to validate data in my MVC project. I have a decimal value that I am entering on a page, but if a comma is included in it then validation fails for it. For example "12,000.00". How can I get FluentValidation to accept such values?


Solution

  • I got this to work by creating a custom binder for decimal values. This should work regardless of what validation tool you're using. See this link on how to do that:

    http://haacked.com/archive/2011/03/19/fixing-binding-to-decimals.aspx/