tags:

views:

46

answers:

1

I am attempting to validate a range dollar amount. The value must be less than (not equal to) the input currency amount, which can be represented in multiple currencies.

How can I represent this value? Should I convert to decimal and subtract 0.01? If that doesn't work, why not? I'm using C#.

I'm possibly over-thinking an obvious solution, so an "Uhhhh do 'X' " type of response would not surprise me.

Thanks for any insight.

A: 

Seeing as how you say it can be in different currencies, Are the values you are comparing both of the same currency? If not then your range will need to be even more dynamic as some foreign currencies may result in a larger number than your initial value.

So for example if you are comparing a USD 100 to YEN which would be about 92 yen per dollar for 9200 yen (on average) for today. that would not really match up. It's best to compare same currency to same currency for ranges.

Also you never said what your range is. You are only talking about your Maximum. What's your min? Is it Zero what if you have a negative amount? If this was a trading application you could have positive and negatives.

Your best bet if you have a maximum value is to convert your entered value to whatever similar currency you have and then adjust validate that it's less than or equal to your max value. Which might be better in a codebehind validation vs a range validator.

So lets assume you are using a trading app. You have a Trade Limit say 1000 USD. The user is doing an international trade in YEN. When you go to do your checks you will have to get the FX Rate for the day, divide it into your YEN entered amount and verify that it's less than or equal to your limit. In a trading scenario you could use an ABS value so that a Buy or Sell net out to the same 1000 limit. Since this is a bit more complicated than a simple range check I would personally recommend doing your own validations either with jQuery / AJAX or just plain code behind.

May make your life much easier.

Joshua Cauble