0

In price mask (imask.js) I use this:

{
   mask: Number,
   signed: true,
   scale: 3,
   normalizeZeros: true,
   padFractionalZeros: true,
   ...
}

This adds max 3 extra zeroes at the end, because the scale is 3. I want to be abble to add max 2, while the scale is 3.

The scale should be 3, but the added extra zeros at the end should be max 2. How to achieve this?

Example:

4 -> 4.00       // extra 2 zeros added
4.5 -> 4.50     // 1 zero added
4.56 -> 4.56    // nothing added
4.50 -> 4.50    // nothing added or removed
4.567 -> 4.567  // nothing added or removed
Oktay Yuzcan
  • 2,097
  • 1
  • 6
  • 15
  • I don't think it can easily be done as is. I'm considering forking the project to modify `padFractionalZeros` to accept a `number` value, and changing the [function that does the padding](https://github.com/uNmAnNeR/imaskjs/blob/a076513f777467b612b6f3671a5d8e5ab98c2fda/packages/imask/src/masked/number.js#L302-L309) – Gabriel Jablonski Dec 06 '22 at 19:48
  • Did some quick testing and it seems to work fine. Here are the changes [https://github.com/gabrieljablonski/imaskjs/commit/b5ab3af661c59620e12538c24d4d07f1e2d26dc9](https://github.com/gabrieljablonski/imaskjs/commit/b5ab3af661c59620e12538c24d4d07f1e2d26dc9) – Gabriel Jablonski Dec 06 '22 at 20:15

0 Answers0