[ic] [interchange] Add numeric ordercheck

Ton Verhagen ton at verhagen.net
Thu Mar 25 17:29:14 UTC 2010


On Mar 25, 2010, at 18:14 PM, Mike Heins wrote:

> Quoting Ton Verhagen (tverhagen at alamerce.nl):
>> 
>> On Mar 25, 2010, at 17:19 PM, Jon Jensen wrote:
>> 
>>> On Thu, 25 Mar 2010, Mike Heins wrote:
>>> 
>>>> Hmm. This is no definition of numeric I know of.
>>>> 
>>>> If it is for a SQL purpose, perhaps. I don't know enough to check that. I will tell you MySQL and Postgres both accept +1, 1. and .1 just fine, as does Perl.
>>> 
>>> Yes, we considered those but decided to make the check restrictive at least to start with. We can loosen it up if needed.
>>> 
>>> The idea was that if validating a numeric entry from a customer, 1. is almost certainly missing something, +1 is not likely intentional, and .1 we were on the fence about -- some cases it might be intentional, other times a mistake.
>>> 
>>>> I think perhaps I would prefer:
>>>> 
>>>> 	use Scalar::Util qw/looks_like_number/;
>>> 
>>> I could see using that. Ton, what do you think?
>> 
>> 
>> The purpose for which we wanted this check was to check on user
>> input (mainly backend) for amounts, like prices etc. Price amounts
>> normally look like 'd.dd' or '-d.dd'. Having prices like '+1.25'
>> input into a table would not make much sense to us. Same for .1 and
>> 1. type of input.
>> 
>> Maybe we should rename the current numeric order check to reflect it's
>> purpose. Or an other idea would be to have a kind of a 'price/amount
>> picture' order check, where the format given should be matched.
> 
> How about using "currency" as the name? That would make me happy.

No problem with that.

Would be nice if we had a 'currency' filter as well. This filter could transform .1 to e.g. 0.10 etc
maybe number of leading zero's and precision (decimal places) configurable, as well as 'sign' accepted or not.

Leaves the challenge coming up with a proper numeric order check.

Best,

Ton




More information about the interchange-users mailing list