0

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?

Rono
  • 2,575
  • 2
  • 24
  • 49
  • You could try a regex validator. Regex example here: http://stackoverflow.com/a/1566016/2181514 – freedomn-m Jun 04 '15 at 13:55
  • 1
    After you solve problem with validation, model-binding problem can become actual http://stackoverflow.com/questions/6520005/problem-with-double-values-binding – Evgeny Levin Jun 04 '15 at 20:56

1 Answers1

0

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/

Rono
  • 2,575
  • 2
  • 24
  • 49