0

When I try to bind a string ("1,000.00") to a decimal property (x) FluentValidation throws the following error: "The value '1,000.00' is not valid for x." I have a DecimalModelBinder that will handle binding the model but FluentValidation prevents me from getting that far. I could strip the comma before the form is submitted but I would rather not handle this for many different fields. I am looking for a way to tell FluentValidation to completely ignore the property and just trust me :).

Thanks in advance for any thoughts or suggestions!

Mike
  • 5,437
  • 7
  • 45
  • 62
  • is this a localization issue or are you forcing the non decimal format for some reason? i.e. what is the source of that string "1,000.00" – rism Feb 28 '15 at 08:19
  • The source of the string is a textbox that requires the format #,###.00 – Mike Mar 02 '15 at 14:23
  • by definition, the model binder converts strings (like from your form post) to 'models', in this case, the C# decimal type. So @amir-gh is correct. Also, the error message is a MVC binder one, not FV. – Raul Nohea Goodness Apr 01 '15 at 01:33

1 Answers1

2

i believe this error does not come from fluentValidaton this error probably generated by MVC modelBinding if your are using MVC as i know fluent validation validating object and you can not create instance of your object and assign string to decimal type. so you should search for problem on your DecimalModelBinder

amir gh
  • 96
  • 1
  • 4