validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

Currency validator rule

Open stevenjlho opened this issue 9 years ago • 3 comments

isCurrency is only accept two digits after decimal_separator. For example, 100.50 is valid, but 100.5 is not valid. I think this rule do not force one digit or two digits after decimal_separator.

stevenjlho avatar Apr 14 '17 02:04 stevenjlho

I believe it currently accepts 0 or 2 places. One place seems to be extremely rare as a standard, although it may exist (Macanese pataca?). Also, there seem to be plenty of examples of 3-decimal-place standards. Maybe this should be a new option that is an array of acceptable numbers of decimal places, defaulting to [0, 2]. I could add this in the next few days unless someone else wants to tackle.

regularmike avatar Apr 14 '17 02:04 regularmike

I agree with you. Add a new option is a good point.

stevenjlho avatar Apr 14 '17 03:04 stevenjlho

@chriso does this sound reasonable? It should definitely support 0 to 3 places according to the ISO standard. I'm not sure if any country officially allows more than one number of decimal places (e.g. 0 or 2) but I can imagine users of this library may want that option.

regularmike avatar Apr 15 '17 15:04 regularmike